src/HOL/Library/positivstellensatz.ML
changeset 60642 48dd1cefb4ae
parent 59586 ddf6deaadfe8
child 60801 7664e0916eec
equal deleted inserted replaced
60641:f6e8293747fd 60642:48dd1cefb4ae
   481     val dest_eq = dest_binary @{cterm "op = :: real => _"}
   481     val dest_eq = dest_binary @{cterm "op = :: real => _"}
   482     val neq_th = nth pth 5
   482     val neq_th = nth pth 5
   483     fun real_not_eq_conv ct =
   483     fun real_not_eq_conv ct =
   484       let
   484       let
   485         val (l,r) = dest_eq (Thm.dest_arg ct)
   485         val (l,r) = dest_eq (Thm.dest_arg ct)
   486         val th = Thm.instantiate ([],[(@{cpat "?x::real"},l),(@{cpat "?y::real"},r)]) neq_th
   486         val th = Thm.instantiate ([],[((("x", 0), @{typ real}),l),((("y", 0), @{typ real}),r)]) neq_th
   487         val th_p = poly_conv(Thm.dest_arg(Thm.dest_arg1(Thm.rhs_of th)))
   487         val th_p = poly_conv(Thm.dest_arg(Thm.dest_arg1(Thm.rhs_of th)))
   488         val th_x = Drule.arg_cong_rule @{cterm "uminus :: real => _"} th_p
   488         val th_x = Drule.arg_cong_rule @{cterm "uminus :: real => _"} th_p
   489         val th_n = fconv_rule (arg_conv poly_neg_conv) th_x
   489         val th_n = fconv_rule (arg_conv poly_neg_conv) th_x
   490         val th' = Drule.binop_cong_rule @{cterm HOL.disj}
   490         val th' = Drule.binop_cong_rule @{cterm HOL.disj}
   491           (Drule.arg_cong_rule (Thm.apply @{cterm "op <::real=>_"} @{cterm "0::real"}) th_p)
   491           (Drule.arg_cong_rule (Thm.apply @{cterm "op <::real=>_"} @{cterm "0::real"}) th_p)
   727     let
   727     let
   728       val pth_abs = instantiate' [SOME @{ctyp real}] [] abs_split'
   728       val pth_abs = instantiate' [SOME @{ctyp real}] [] abs_split'
   729       val pth_max = instantiate' [SOME @{ctyp real}] [] max_split
   729       val pth_max = instantiate' [SOME @{ctyp real}] [] max_split
   730       val pth_min = instantiate' [SOME @{ctyp real}] [] min_split
   730       val pth_min = instantiate' [SOME @{ctyp real}] [] min_split
   731       val abs_tm = @{cterm "abs :: real => _"}
   731       val abs_tm = @{cterm "abs :: real => _"}
   732       val p_tm = @{cpat "?P :: real => bool"}
   732       val p_v = (("P", 0), @{typ "real \<Rightarrow> bool"})
   733       val x_tm = @{cpat "?x :: real"}
   733       val x_v = (("x", 0), @{typ real})
   734       val y_tm = @{cpat "?y::real"}
   734       val y_v = (("y", 0), @{typ real})
   735       val is_max = is_binop @{cterm "max :: real => _"}
   735       val is_max = is_binop @{cterm "max :: real => _"}
   736       val is_min = is_binop @{cterm "min :: real => _"}
   736       val is_min = is_binop @{cterm "min :: real => _"}
   737       fun is_abs t = is_comb t andalso Thm.dest_fun t aconvc abs_tm
   737       fun is_abs t = is_comb t andalso Thm.dest_fun t aconvc abs_tm
   738       fun eliminate_construct p c tm =
   738       fun eliminate_construct p c tm =
   739         let
   739         let
   744                      (Thm.transitive th0 (c p ax))
   744                      (Thm.transitive th0 (c p ax))
   745         end
   745         end
   746 
   746 
   747       val elim_abs = eliminate_construct is_abs
   747       val elim_abs = eliminate_construct is_abs
   748         (fn p => fn ax =>
   748         (fn p => fn ax =>
   749           Thm.instantiate ([], [(p_tm,p), (x_tm, Thm.dest_arg ax)]) pth_abs)
   749           Thm.instantiate ([], [(p_v,p), (x_v, Thm.dest_arg ax)]) pth_abs)
   750       val elim_max = eliminate_construct is_max
   750       val elim_max = eliminate_construct is_max
   751         (fn p => fn ax =>
   751         (fn p => fn ax =>
   752           let val (ax,y) = Thm.dest_comb ax
   752           let val (ax,y) = Thm.dest_comb ax
   753           in Thm.instantiate ([], [(p_tm,p), (x_tm, Thm.dest_arg ax), (y_tm,y)])
   753           in Thm.instantiate ([], [(p_v,p), (x_v, Thm.dest_arg ax), (y_v,y)])
   754                              pth_max end)
   754                              pth_max end)
   755       val elim_min = eliminate_construct is_min
   755       val elim_min = eliminate_construct is_min
   756         (fn p => fn ax =>
   756         (fn p => fn ax =>
   757           let val (ax,y) = Thm.dest_comb ax
   757           let val (ax,y) = Thm.dest_comb ax
   758           in Thm.instantiate ([], [(p_tm,p), (x_tm, Thm.dest_arg ax), (y_tm,y)])
   758           in Thm.instantiate ([], [(p_v,p), (x_v, Thm.dest_arg ax), (y_v,y)])
   759                              pth_min end)
   759                              pth_min end)
   760     in first_conv [elim_abs, elim_max, elim_min, all_conv]
   760     in first_conv [elim_abs, elim_max, elim_min, all_conv]
   761     end;
   761     end;
   762 in
   762 in
   763 fun gen_real_arith ctxt (mkconst,eq,ge,gt,norm,neg,add,mul,prover) =
   763 fun gen_real_arith ctxt (mkconst,eq,ge,gt,norm,neg,add,mul,prover) =