src/HOL/Library/positivstellensatz.ML
changeset 38549 d0385f2764d8
parent 37598 893dcabf0c04
child 38558 32ad17fe2b9c
equal deleted inserted replaced
38548:dea0d2cca822 38549:d0385f2764d8
   496   end
   496   end
   497  (* FIXME!!! Copied from groebner.ml *)
   497  (* FIXME!!! Copied from groebner.ml *)
   498  val strip_exists =
   498  val strip_exists =
   499   let fun h (acc, t) =
   499   let fun h (acc, t) =
   500    case (term_of t) of
   500    case (term_of t) of
   501     Const("Ex",_)$Abs(x,T,p) => h (Thm.dest_abs NONE (Thm.dest_arg t) |>> (fn v => v::acc))
   501     Const(@{const_name "Ex"},_)$Abs(x,T,p) => h (Thm.dest_abs NONE (Thm.dest_arg t) |>> (fn v => v::acc))
   502   | _ => (acc,t)
   502   | _ => (acc,t)
   503   in fn t => h ([],t)
   503   in fn t => h ([],t)
   504   end
   504   end
   505   fun name_of x = case term_of x of
   505   fun name_of x = case term_of x of
   506    Free(s,_) => s
   506    Free(s,_) => s
   513 
   513 
   514  fun ext T = Drule.cterm_rule (instantiate' [SOME T] []) @{cpat Ex}
   514  fun ext T = Drule.cterm_rule (instantiate' [SOME T] []) @{cpat Ex}
   515  fun mk_ex v t = Thm.capply (ext (ctyp_of_term v)) (Thm.cabs v t)
   515  fun mk_ex v t = Thm.capply (ext (ctyp_of_term v)) (Thm.cabs v t)
   516 
   516 
   517  fun choose v th th' = case concl_of th of 
   517  fun choose v th th' = case concl_of th of 
   518    @{term Trueprop} $ (Const("Ex",_)$_) => 
   518    @{term Trueprop} $ (Const(@{const_name "Ex"},_)$_) => 
   519     let
   519     let
   520      val p = (funpow 2 Thm.dest_arg o cprop_of) th
   520      val p = (funpow 2 Thm.dest_arg o cprop_of) th
   521      val T = (hd o Thm.dest_ctyp o ctyp_of_term) p
   521      val T = (hd o Thm.dest_ctyp o ctyp_of_term) p
   522      val th0 = fconv_rule (Thm.beta_conversion true)
   522      val th0 = fconv_rule (Thm.beta_conversion true)
   523          (instantiate' [SOME T] [SOME p, (SOME o Thm.dest_arg o cprop_of) th'] exE)
   523          (instantiate' [SOME T] [SOME p, (SOME o Thm.dest_arg o cprop_of) th'] exE)
   531      choose v (Thm.assume ((Thm.capply @{cterm Trueprop} o mk_ex v) ((Thm.dest_arg o hd o #hyps o Thm.crep_thm) th))) th
   531      choose v (Thm.assume ((Thm.capply @{cterm Trueprop} o mk_ex v) ((Thm.dest_arg o hd o #hyps o Thm.crep_thm) th))) th
   532 
   532 
   533  val strip_forall =
   533  val strip_forall =
   534   let fun h (acc, t) =
   534   let fun h (acc, t) =
   535    case (term_of t) of
   535    case (term_of t) of
   536     Const("All",_)$Abs(x,T,p) => h (Thm.dest_abs NONE (Thm.dest_arg t) |>> (fn v => v::acc))
   536     Const(@{const_name "All"},_)$Abs(x,T,p) => h (Thm.dest_abs NONE (Thm.dest_arg t) |>> (fn v => v::acc))
   537   | _ => (acc,t)
   537   | _ => (acc,t)
   538   in fn t => h ([],t)
   538   in fn t => h ([],t)
   539   end
   539   end
   540 
   540 
   541  fun f ct =
   541  fun f ct =