src/HOL/Library/positivstellensatz.ML
changeset 32828 ad76967c703d
parent 32740 9dd0a2f83429
child 32829 671eb46eb0a3
     1.1 --- a/src/HOL/Library/positivstellensatz.ML	Thu Oct 01 18:59:26 2009 +0200
     1.2 +++ b/src/HOL/Library/positivstellensatz.ML	Tue Sep 22 14:17:54 2009 +0200
     1.3 @@ -165,7 +165,7 @@
     1.4  structure RealArith : REAL_ARITH =
     1.5  struct
     1.6  
     1.7 - open Conv Thm FuncUtil;;
     1.8 + open Conv
     1.9  (* ------------------------------------------------------------------------- *)
    1.10  (* Data structure for Positivstellensatz refutations.                        *)
    1.11  (* ------------------------------------------------------------------------- *)
    1.12 @@ -353,36 +353,31 @@
    1.13  
    1.14  (* Map back polynomials to HOL.                         *)
    1.15  
    1.16 -local
    1.17 - open Thm Numeral
    1.18 -in
    1.19 -
    1.20 -fun cterm_of_varpow x k = if k = 1 then x else capply (capply @{cterm "op ^ :: real => _"} x) 
    1.21 -  (mk_cnumber @{ctyp nat} k)
    1.22 +fun cterm_of_varpow x k = if k = 1 then x else Thm.capply (Thm.capply @{cterm "op ^ :: real => _"} x) 
    1.23 +  (Numeral.mk_cnumber @{ctyp nat} k)
    1.24  
    1.25  fun cterm_of_monomial m = 
    1.26 - if Ctermfunc.is_undefined m then @{cterm "1::real"} 
    1.27 + if FuncUtil.Ctermfunc.is_undefined m then @{cterm "1::real"} 
    1.28   else 
    1.29    let 
    1.30 -   val m' = dest_monomial m
    1.31 +   val m' = FuncUtil.dest_monomial m
    1.32     val vps = fold_rev (fn (x,k) => cons (cterm_of_varpow x k)) m' [] 
    1.33 -  in foldr1 (fn (s, t) => capply (capply @{cterm "op * :: real => _"} s) t) vps
    1.34 +  in foldr1 (fn (s, t) => Thm.capply (Thm.capply @{cterm "op * :: real => _"} s) t) vps
    1.35    end
    1.36  
    1.37 -fun cterm_of_cmonomial (m,c) = if Ctermfunc.is_undefined m then cterm_of_rat c
    1.38 +fun cterm_of_cmonomial (m,c) = if FuncUtil.Ctermfunc.is_undefined m then cterm_of_rat c
    1.39      else if c = Rat.one then cterm_of_monomial m
    1.40 -    else capply (capply @{cterm "op *::real => _"} (cterm_of_rat c)) (cterm_of_monomial m);
    1.41 +    else Thm.capply (Thm.capply @{cterm "op *::real => _"} (cterm_of_rat c)) (cterm_of_monomial m);
    1.42  
    1.43  fun cterm_of_poly p = 
    1.44 - if Monomialfunc.is_undefined p then @{cterm "0::real"} 
    1.45 + if FuncUtil.Monomialfunc.is_undefined p then @{cterm "0::real"} 
    1.46   else
    1.47    let 
    1.48     val cms = map cterm_of_cmonomial
    1.49 -     (sort (prod_ord monomial_order (K EQUAL)) (Monomialfunc.graph p))
    1.50 -  in foldr1 (fn (t1, t2) => capply(capply @{cterm "op + :: real => _"} t1) t2) cms
    1.51 +     (sort (prod_ord FuncUtil.monomial_order (K EQUAL)) (FuncUtil.Monomialfunc.graph p))
    1.52 +  in foldr1 (fn (t1, t2) => Thm.capply(Thm.capply @{cterm "op + :: real => _"} t1) t2) cms
    1.53    end;
    1.54  
    1.55 -end;
    1.56      (* A general real arithmetic prover *)
    1.57  
    1.58  fun gen_gen_real_arith ctxt (mk_numeric,
    1.59 @@ -390,7 +385,6 @@
    1.60         poly_conv,poly_neg_conv,poly_add_conv,poly_mul_conv,
    1.61         absconv1,absconv2,prover) = 
    1.62  let
    1.63 - open Conv Thm;
    1.64   val _ = my_context := ctxt 
    1.65   val _ = (my_mk_numeric := mk_numeric ; my_numeric_eq_conv := numeric_eq_conv ; 
    1.66            my_numeric_ge_conv := numeric_ge_conv; my_numeric_gt_conv := numeric_gt_conv ;
    1.67 @@ -414,7 +408,7 @@
    1.68  
    1.69   fun real_ineq_conv th ct =
    1.70    let
    1.71 -   val th' = (instantiate (match (lhs_of th, ct)) th 
    1.72 +   val th' = (Thm.instantiate (Thm.match (Thm.lhs_of th, ct)) th 
    1.73        handle MATCH => raise CTERM ("real_ineq_conv", [ct]))
    1.74    in transitive th' (oprconv poly_conv (Thm.rhs_of th'))
    1.75    end 
    1.76 @@ -442,14 +436,14 @@
    1.77          Axiom_eq n => nth eqs n
    1.78        | Axiom_le n => nth les n
    1.79        | Axiom_lt n => nth lts n
    1.80 -      | Rational_eq x => eqT_elim(numeric_eq_conv(capply @{cterm Trueprop} 
    1.81 -                          (capply (capply @{cterm "op =::real => _"} (mk_numeric x)) 
    1.82 +      | Rational_eq x => eqT_elim(numeric_eq_conv(Thm.capply @{cterm Trueprop} 
    1.83 +                          (Thm.capply (Thm.capply @{cterm "op =::real => _"} (mk_numeric x)) 
    1.84                                 @{cterm "0::real"})))
    1.85 -      | Rational_le x => eqT_elim(numeric_ge_conv(capply @{cterm Trueprop} 
    1.86 -                          (capply (capply @{cterm "op <=::real => _"} 
    1.87 +      | Rational_le x => eqT_elim(numeric_ge_conv(Thm.capply @{cterm Trueprop} 
    1.88 +                          (Thm.capply (Thm.capply @{cterm "op <=::real => _"} 
    1.89                                       @{cterm "0::real"}) (mk_numeric x))))
    1.90 -      | Rational_lt x => eqT_elim(numeric_gt_conv(capply @{cterm Trueprop} 
    1.91 -                      (capply (capply @{cterm "op <::real => _"} @{cterm "0::real"})
    1.92 +      | Rational_lt x => eqT_elim(numeric_gt_conv(Thm.capply @{cterm Trueprop} 
    1.93 +                      (Thm.capply (Thm.capply @{cterm "op <::real => _"} @{cterm "0::real"})
    1.94                          (mk_numeric x))))
    1.95        | Square pt => square_rule (cterm_of_poly pt)
    1.96        | Eqmul(pt,p) => emul_rule (cterm_of_poly pt) (translate p)
    1.97 @@ -463,8 +457,8 @@
    1.98        nnf_conv then_conv skolemize_conv then_conv prenex_conv then_conv
    1.99        weak_dnf_conv
   1.100  
   1.101 -  val concl = dest_arg o cprop_of
   1.102 -  fun is_binop opr ct = (dest_fun2 ct aconvc opr handle CTERM _ => false)
   1.103 +  val concl = Thm.dest_arg o cprop_of
   1.104 +  fun is_binop opr ct = (Thm.dest_fun2 ct aconvc opr handle CTERM _ => false)
   1.105    val is_req = is_binop @{cterm "op =:: real => _"}
   1.106    val is_ge = is_binop @{cterm "op <=:: real => _"}
   1.107    val is_gt = is_binop @{cterm "op <:: real => _"}
   1.108 @@ -472,10 +466,13 @@
   1.109    val is_disj = is_binop @{cterm "op |"}
   1.110    fun conj_pair th = (th RS @{thm conjunct1}, th RS @{thm conjunct2})
   1.111    fun disj_cases th th1 th2 = 
   1.112 -   let val (p,q) = dest_binop (concl th)
   1.113 +   let val (p,q) = Thm.dest_binop (concl th)
   1.114         val c = concl th1
   1.115         val _ = if c aconvc (concl th2) then () else error "disj_cases : conclusions not alpha convertible"
   1.116 -   in implies_elim (implies_elim (implies_elim (instantiate' [] (map SOME [p,q,c]) @{thm disjE}) th) (implies_intr (capply @{cterm Trueprop} p) th1)) (implies_intr (capply @{cterm Trueprop} q) th2)
   1.117 +   in implies_elim (implies_elim
   1.118 +          (implies_elim (instantiate' [] (map SOME [p,q,c]) @{thm disjE}) th)
   1.119 +          (implies_intr (Thm.capply @{cterm Trueprop} p) th1))
   1.120 +        (implies_intr (Thm.capply @{cterm Trueprop} q) th2)
   1.121     end
   1.122   fun overall cert_choice dun ths = case ths of
   1.123    [] =>
   1.124 @@ -494,37 +491,37 @@
   1.125        overall cert_choice dun (th1::th2::oths) end
   1.126      else if is_disj ct then
   1.127        let 
   1.128 -       val (th1, cert1) = overall (Left::cert_choice) dun (assume (capply @{cterm Trueprop} (dest_arg1 ct))::oths)
   1.129 -       val (th2, cert2) = overall (Right::cert_choice) dun (assume (capply @{cterm Trueprop} (dest_arg ct))::oths)
   1.130 +       val (th1, cert1) = overall (Left::cert_choice) dun (assume (Thm.capply @{cterm Trueprop} (Thm.dest_arg1 ct))::oths)
   1.131 +       val (th2, cert2) = overall (Right::cert_choice) dun (assume (Thm.capply @{cterm Trueprop} (Thm.dest_arg ct))::oths)
   1.132        in (disj_cases th th1 th2, Branch (cert1, cert2)) end
   1.133     else overall cert_choice (th::dun) oths
   1.134    end
   1.135 -  fun dest_binary b ct = if is_binop b ct then dest_binop ct 
   1.136 +  fun dest_binary b ct = if is_binop b ct then Thm.dest_binop ct 
   1.137                           else raise CTERM ("dest_binary",[b,ct])
   1.138    val dest_eq = dest_binary @{cterm "op = :: real => _"}
   1.139    val neq_th = nth pth 5
   1.140    fun real_not_eq_conv ct = 
   1.141     let 
   1.142 -    val (l,r) = dest_eq (dest_arg ct)
   1.143 -    val th = instantiate ([],[(@{cpat "?x::real"},l),(@{cpat "?y::real"},r)]) neq_th
   1.144 -    val th_p = poly_conv(dest_arg(dest_arg1(rhs_of th)))
   1.145 +    val (l,r) = dest_eq (Thm.dest_arg ct)
   1.146 +    val th = Thm.instantiate ([],[(@{cpat "?x::real"},l),(@{cpat "?y::real"},r)]) neq_th
   1.147 +    val th_p = poly_conv(Thm.dest_arg(Thm.dest_arg1(Thm.rhs_of th)))
   1.148      val th_x = Drule.arg_cong_rule @{cterm "uminus :: real => _"} th_p
   1.149      val th_n = fconv_rule (arg_conv poly_neg_conv) th_x
   1.150      val th' = Drule.binop_cong_rule @{cterm "op |"} 
   1.151 -     (Drule.arg_cong_rule (capply @{cterm "op <::real=>_"} @{cterm "0::real"}) th_p)
   1.152 -     (Drule.arg_cong_rule (capply @{cterm "op <::real=>_"} @{cterm "0::real"}) th_n)
   1.153 +     (Drule.arg_cong_rule (Thm.capply @{cterm "op <::real=>_"} @{cterm "0::real"}) th_p)
   1.154 +     (Drule.arg_cong_rule (Thm.capply @{cterm "op <::real=>_"} @{cterm "0::real"}) th_n)
   1.155      in transitive th th' 
   1.156    end
   1.157   fun equal_implies_1_rule PQ = 
   1.158    let 
   1.159 -   val P = lhs_of PQ
   1.160 +   val P = Thm.lhs_of PQ
   1.161    in implies_intr P (equal_elim PQ (assume P))
   1.162    end
   1.163   (* FIXME!!! Copied from groebner.ml *)
   1.164   val strip_exists =
   1.165    let fun h (acc, t) =
   1.166     case (term_of t) of
   1.167 -    Const("Ex",_)$Abs(x,T,p) => h (dest_abs NONE (dest_arg t) |>> (fn v => v::acc))
   1.168 +    Const("Ex",_)$Abs(x,T,p) => h (Thm.dest_abs NONE (Thm.dest_arg t) |>> (fn v => v::acc))
   1.169    | _ => (acc,t)
   1.170    in fn t => h ([],t)
   1.171    end
   1.172 @@ -559,7 +556,7 @@
   1.173   val strip_forall =
   1.174    let fun h (acc, t) =
   1.175     case (term_of t) of
   1.176 -    Const("All",_)$Abs(x,T,p) => h (dest_abs NONE (dest_arg t) |>> (fn v => v::acc))
   1.177 +    Const("All",_)$Abs(x,T,p) => h (Thm.dest_abs NONE (Thm.dest_arg t) |>> (fn v => v::acc))
   1.178    | _ => (acc,t)
   1.179    in fn t => h ([],t)
   1.180    end
   1.181 @@ -576,16 +573,16 @@
   1.182    fun absremover ct = (literals_conv [@{term "op &"}, @{term "op |"}] [] 
   1.183                    (try_conv (absconv1 then_conv binop_conv (arg_conv poly_conv))) then_conv 
   1.184          try_conv (absconv2 then_conv nnf_norm_conv' then_conv binop_conv absremover)) ct
   1.185 -  val nct = capply @{cterm Trueprop} (capply @{cterm "Not"} ct)
   1.186 +  val nct = Thm.capply @{cterm Trueprop} (Thm.capply @{cterm "Not"} ct)
   1.187    val th0 = (init_conv then_conv arg_conv nnf_norm_conv') nct
   1.188 -  val tm0 = dest_arg (rhs_of th0)
   1.189 +  val tm0 = Thm.dest_arg (Thm.rhs_of th0)
   1.190    val (th, certificates) = if tm0 aconvc @{cterm False} then (equal_implies_1_rule th0, Trivial) else
   1.191     let 
   1.192      val (evs,bod) = strip_exists tm0
   1.193      val (avs,ibod) = strip_forall bod
   1.194      val th1 = Drule.arg_cong_rule @{cterm Trueprop} (fold mk_forall avs (absremover ibod))
   1.195 -    val (th2, certs) = overall [] [] [specl avs (assume (rhs_of th1))]
   1.196 -    val th3 = fold simple_choose evs (prove_hyp (equal_elim th1 (assume (capply @{cterm Trueprop} bod))) th2)
   1.197 +    val (th2, certs) = overall [] [] [specl avs (assume (Thm.rhs_of th1))]
   1.198 +    val th3 = fold simple_choose evs (prove_hyp (equal_elim th1 (assume (Thm.capply @{cterm Trueprop} bod))) th2)
   1.199     in (Drule.implies_intr_hyps (prove_hyp (equal_elim th0 (assume nct)) th3), certs)
   1.200     end
   1.201    in (implies_elim (instantiate' [] [SOME ct] pth_final) th, certificates)
   1.202 @@ -595,11 +592,11 @@
   1.203  
   1.204  (* A linear arithmetic prover *)
   1.205  local
   1.206 -  val linear_add = Ctermfunc.combine (curry op +/) (fn z => z =/ Rat.zero)
   1.207 -  fun linear_cmul c = Ctermfunc.mapf (fn x => c */ x)
   1.208 +  val linear_add = FuncUtil.Ctermfunc.combine (curry op +/) (fn z => z =/ Rat.zero)
   1.209 +  fun linear_cmul c = FuncUtil.Ctermfunc.mapf (fn x => c */ x)
   1.210    val one_tm = @{cterm "1::real"}
   1.211 -  fun contradictory p (e,_) = ((Ctermfunc.is_undefined e) andalso not(p Rat.zero)) orelse
   1.212 -     ((gen_eq_set (op aconvc) (Ctermfunc.dom e, [one_tm])) andalso not(p(Ctermfunc.apply e one_tm)))
   1.213 +  fun contradictory p (e,_) = ((FuncUtil.Ctermfunc.is_undefined e) andalso not(p Rat.zero)) orelse
   1.214 +     ((gen_eq_set (op aconvc) (FuncUtil.Ctermfunc.dom e, [one_tm])) andalso not(p(FuncUtil.Ctermfunc.apply e one_tm)))
   1.215  
   1.216    fun linear_ineqs vars (les,lts) = 
   1.217     case find_first (contradictory (fn x => x >/ Rat.zero)) lts of
   1.218 @@ -612,15 +609,15 @@
   1.219       let 
   1.220        val ineqs = les @ lts
   1.221        fun blowup v =
   1.222 -       length(filter (fn (e,_) => Ctermfunc.tryapplyd e v Rat.zero =/ Rat.zero) ineqs) +
   1.223 -       length(filter (fn (e,_) => Ctermfunc.tryapplyd e v Rat.zero >/ Rat.zero) ineqs) *
   1.224 -       length(filter (fn (e,_) => Ctermfunc.tryapplyd e v Rat.zero </ Rat.zero) ineqs)
   1.225 +       length(filter (fn (e,_) => FuncUtil.Ctermfunc.tryapplyd e v Rat.zero =/ Rat.zero) ineqs) +
   1.226 +       length(filter (fn (e,_) => FuncUtil.Ctermfunc.tryapplyd e v Rat.zero >/ Rat.zero) ineqs) *
   1.227 +       length(filter (fn (e,_) => FuncUtil.Ctermfunc.tryapplyd e v Rat.zero </ Rat.zero) ineqs)
   1.228        val  v = fst(hd(sort (fn ((_,i),(_,j)) => int_ord (i,j))
   1.229                   (map (fn v => (v,blowup v)) vars)))
   1.230        fun addup (e1,p1) (e2,p2) acc =
   1.231         let 
   1.232 -        val c1 = Ctermfunc.tryapplyd e1 v Rat.zero 
   1.233 -        val c2 = Ctermfunc.tryapplyd e2 v Rat.zero
   1.234 +        val c1 = FuncUtil.Ctermfunc.tryapplyd e1 v Rat.zero 
   1.235 +        val c2 = FuncUtil.Ctermfunc.tryapplyd e2 v Rat.zero
   1.236         in if c1 */ c2 >=/ Rat.zero then acc else
   1.237          let 
   1.238           val e1' = linear_cmul (Rat.abs c2) e1
   1.239 @@ -631,13 +628,13 @@
   1.240          end
   1.241         end
   1.242        val (les0,les1) = 
   1.243 -         List.partition (fn (e,_) => Ctermfunc.tryapplyd e v Rat.zero =/ Rat.zero) les
   1.244 +         List.partition (fn (e,_) => FuncUtil.Ctermfunc.tryapplyd e v Rat.zero =/ Rat.zero) les
   1.245        val (lts0,lts1) = 
   1.246 -         List.partition (fn (e,_) => Ctermfunc.tryapplyd e v Rat.zero =/ Rat.zero) lts
   1.247 +         List.partition (fn (e,_) => FuncUtil.Ctermfunc.tryapplyd e v Rat.zero =/ Rat.zero) lts
   1.248        val (lesp,lesn) = 
   1.249 -         List.partition (fn (e,_) => Ctermfunc.tryapplyd e v Rat.zero >/ Rat.zero) les1
   1.250 +         List.partition (fn (e,_) => FuncUtil.Ctermfunc.tryapplyd e v Rat.zero >/ Rat.zero) les1
   1.251        val (ltsp,ltsn) = 
   1.252 -         List.partition (fn (e,_) => Ctermfunc.tryapplyd e v Rat.zero >/ Rat.zero) lts1
   1.253 +         List.partition (fn (e,_) => FuncUtil.Ctermfunc.tryapplyd e v Rat.zero >/ Rat.zero) lts1
   1.254        val les' = fold_rev (fn ep1 => fold_rev (addup ep1) lesp) lesn les0
   1.255        val lts' = fold_rev (fn ep1 => fold_rev (addup ep1) (lesp@ltsp)) ltsn
   1.256                        (fold_rev (fn ep1 => fold_rev (addup ep1) (lesn@ltsn)) ltsp lts0)
   1.257 @@ -650,20 +647,20 @@
   1.258    | NONE => (case eqs of 
   1.259      [] => 
   1.260       let val vars = remove (op aconvc) one_tm 
   1.261 -           (fold_rev (curry (gen_union (op aconvc)) o Ctermfunc.dom o fst) (les@lts) []) 
   1.262 +           (fold_rev (curry (gen_union (op aconvc)) o FuncUtil.Ctermfunc.dom o fst) (les@lts) []) 
   1.263       in linear_ineqs vars (les,lts) end
   1.264     | (e,p)::es => 
   1.265 -     if Ctermfunc.is_undefined e then linear_eqs (es,les,lts) else
   1.266 +     if FuncUtil.Ctermfunc.is_undefined e then linear_eqs (es,les,lts) else
   1.267       let 
   1.268 -      val (x,c) = Ctermfunc.choose (Ctermfunc.undefine one_tm e)
   1.269 +      val (x,c) = FuncUtil.Ctermfunc.choose (FuncUtil.Ctermfunc.undefine one_tm e)
   1.270        fun xform (inp as (t,q)) =
   1.271 -       let val d = Ctermfunc.tryapplyd t x Rat.zero in
   1.272 +       let val d = FuncUtil.Ctermfunc.tryapplyd t x Rat.zero in
   1.273          if d =/ Rat.zero then inp else
   1.274          let 
   1.275           val k = (Rat.neg d) */ Rat.abs c // c
   1.276           val e' = linear_cmul k e
   1.277           val t' = linear_cmul (Rat.abs c) t
   1.278 -         val p' = Eqmul(Monomialfunc.onefunc (Ctermfunc.undefined, k),p)
   1.279 +         val p' = Eqmul(FuncUtil.Monomialfunc.onefunc (FuncUtil.Ctermfunc.undefined, k),p)
   1.280           val q' = Product(Rational_lt(Rat.abs c),q) 
   1.281          in (linear_add e' t',Sum(p',q')) 
   1.282          end 
   1.283 @@ -680,19 +677,19 @@
   1.284     end 
   1.285    
   1.286    fun lin_of_hol ct = 
   1.287 -   if ct aconvc @{cterm "0::real"} then Ctermfunc.undefined
   1.288 -   else if not (is_comb ct) then Ctermfunc.onefunc (ct, Rat.one)
   1.289 -   else if is_ratconst ct then Ctermfunc.onefunc (one_tm, dest_ratconst ct)
   1.290 +   if ct aconvc @{cterm "0::real"} then FuncUtil.Ctermfunc.undefined
   1.291 +   else if not (is_comb ct) then FuncUtil.Ctermfunc.onefunc (ct, Rat.one)
   1.292 +   else if is_ratconst ct then FuncUtil.Ctermfunc.onefunc (one_tm, dest_ratconst ct)
   1.293     else
   1.294      let val (lop,r) = Thm.dest_comb ct 
   1.295 -    in if not (is_comb lop) then Ctermfunc.onefunc (ct, Rat.one)
   1.296 +    in if not (is_comb lop) then FuncUtil.Ctermfunc.onefunc (ct, Rat.one)
   1.297         else
   1.298          let val (opr,l) = Thm.dest_comb lop 
   1.299          in if opr aconvc @{cterm "op + :: real =>_"} 
   1.300             then linear_add (lin_of_hol l) (lin_of_hol r)
   1.301             else if opr aconvc @{cterm "op * :: real =>_"} 
   1.302 -                   andalso is_ratconst l then Ctermfunc.onefunc (r, dest_ratconst l)
   1.303 -           else Ctermfunc.onefunc (ct, Rat.one)
   1.304 +                   andalso is_ratconst l then FuncUtil.Ctermfunc.onefunc (r, dest_ratconst l)
   1.305 +           else FuncUtil.Ctermfunc.onefunc (ct, Rat.one)
   1.306          end
   1.307      end
   1.308  
   1.309 @@ -700,21 +697,20 @@
   1.310     Const(@{const_name "real"}, _)$ n => 
   1.311       if can HOLogic.dest_number n then false else true
   1.312    | _ => false
   1.313 - open Thm
   1.314  in 
   1.315  fun real_linear_prover translator (eq,le,lt) = 
   1.316   let 
   1.317 -  val lhs = lin_of_hol o dest_arg1 o dest_arg o cprop_of
   1.318 -  val rhs = lin_of_hol o dest_arg o dest_arg o cprop_of
   1.319 +  val lhs = lin_of_hol o Thm.dest_arg1 o Thm.dest_arg o cprop_of
   1.320 +  val rhs = lin_of_hol o Thm.dest_arg o Thm.dest_arg o cprop_of
   1.321    val eq_pols = map lhs eq
   1.322    val le_pols = map rhs le
   1.323    val lt_pols = map rhs lt 
   1.324    val aliens =  filter is_alien
   1.325 -      (fold_rev (curry (gen_union (op aconvc)) o Ctermfunc.dom) 
   1.326 +      (fold_rev (curry (gen_union (op aconvc)) o FuncUtil.Ctermfunc.dom) 
   1.327            (eq_pols @ le_pols @ lt_pols) [])
   1.328 -  val le_pols' = le_pols @ map (fn v => Ctermfunc.onefunc (v,Rat.one)) aliens
   1.329 +  val le_pols' = le_pols @ map (fn v => FuncUtil.Ctermfunc.onefunc (v,Rat.one)) aliens
   1.330    val (_,proof) = linear_prover (eq_pols,le_pols',lt_pols)
   1.331 -  val le' = le @ map (fn a => instantiate' [] [SOME (dest_arg a)] @{thm real_of_nat_ge_zero}) aliens 
   1.332 +  val le' = le @ map (fn a => instantiate' [] [SOME (Thm.dest_arg a)] @{thm real_of_nat_ge_zero}) aliens 
   1.333   in ((translator (eq,le',lt) proof), Trivial)
   1.334   end
   1.335  end;
   1.336 @@ -737,28 +733,28 @@
   1.337     val y_tm = @{cpat "?y::real"}
   1.338     val is_max = is_binop @{cterm "max :: real => _"}
   1.339     val is_min = is_binop @{cterm "min :: real => _"} 
   1.340 -   fun is_abs t = is_comb t andalso dest_fun t aconvc abs_tm
   1.341 +   fun is_abs t = is_comb t andalso Thm.dest_fun t aconvc abs_tm
   1.342     fun eliminate_construct p c tm =
   1.343      let 
   1.344       val t = find_cterm p tm
   1.345 -     val th0 = (symmetric o beta_conversion false) (capply (cabs t tm) t)
   1.346 -     val (p,ax) = (dest_comb o rhs_of) th0
   1.347 +     val th0 = (symmetric o beta_conversion false) (Thm.capply (Thm.cabs t tm) t)
   1.348 +     val (p,ax) = (Thm.dest_comb o Thm.rhs_of) th0
   1.349      in fconv_rule(arg_conv(binop_conv (arg_conv (beta_conversion false))))
   1.350                 (transitive th0 (c p ax))
   1.351     end
   1.352  
   1.353     val elim_abs = eliminate_construct is_abs
   1.354      (fn p => fn ax => 
   1.355 -       instantiate ([], [(p_tm,p), (x_tm, dest_arg ax)]) pth_abs)
   1.356 +       Thm.instantiate ([], [(p_tm,p), (x_tm, Thm.dest_arg ax)]) pth_abs)
   1.357     val elim_max = eliminate_construct is_max
   1.358      (fn p => fn ax => 
   1.359 -      let val (ax,y) = dest_comb ax 
   1.360 -      in  instantiate ([], [(p_tm,p), (x_tm, dest_arg ax), (y_tm,y)]) 
   1.361 +      let val (ax,y) = Thm.dest_comb ax 
   1.362 +      in  Thm.instantiate ([], [(p_tm,p), (x_tm, Thm.dest_arg ax), (y_tm,y)]) 
   1.363        pth_max end)
   1.364     val elim_min = eliminate_construct is_min
   1.365      (fn p => fn ax => 
   1.366 -      let val (ax,y) = dest_comb ax 
   1.367 -      in  instantiate ([], [(p_tm,p), (x_tm, dest_arg ax), (y_tm,y)]) 
   1.368 +      let val (ax,y) = Thm.dest_comb ax 
   1.369 +      in  Thm.instantiate ([], [(p_tm,p), (x_tm, Thm.dest_arg ax), (y_tm,y)]) 
   1.370        pth_min end)
   1.371     in first_conv [elim_abs, elim_max, elim_min, all_conv]
   1.372    end;