# HG changeset patch # User wenzelm # Date 1514052131 -3600 # Node ID 48ef58c6cf4c46b3b5f154b4693185c658dce841 # Parent f18c774acde426d7f963291d616452a7d505d6fd more symbols; diff -r f18c774acde4 -r 48ef58c6cf4c src/HOL/Library/Sum_of_Squares/positivstellensatz_tools.ML --- a/src/HOL/Library/Sum_of_Squares/positivstellensatz_tools.ML Fri Dec 22 23:38:54 2017 +0000 +++ b/src/HOL/Library/Sum_of_Squares/positivstellensatz_tools.ML Sat Dec 23 19:02:11 2017 +0100 @@ -105,7 +105,7 @@ val parse_id = Scan.one Symbol.is_letter ::: Scan.many Symbol.is_letdig >> implode fun parse_varpow ctxt = parse_id -- Scan.optional (str "^" |-- nat) 1 >> - (fn (x, k) => (Thm.cterm_of ctxt (Free (x, @{typ real})), k)) + (fn (x, k) => (Thm.cterm_of ctxt (Free (x, \<^typ>\real\)), k)) fun parse_monomial ctxt = repeat_sep "*" (parse_varpow ctxt) >> (fn xs => fold FuncUtil.Ctermfunc.update xs FuncUtil.Ctermfunc.empty) diff -r f18c774acde4 -r 48ef58c6cf4c src/HOL/Library/Sum_of_Squares/sum_of_squares.ML --- a/src/HOL/Library/Sum_of_Squares/sum_of_squares.ML Fri Dec 22 23:38:54 2017 +0000 +++ b/src/HOL/Library/Sum_of_Squares/sum_of_squares.ML Sat Dec 23 19:02:11 2017 +0100 @@ -48,8 +48,8 @@ in s (if x2 >= b then d + 1 else d) end -val trace = Attrib.setup_config_bool @{binding sos_trace} (K false); -val debug = Attrib.setup_config_bool @{binding sos_debug} (K false); +val trace = Attrib.setup_config_bool \<^binding>\sos_trace\ (K false); +val debug = Attrib.setup_config_bool \<^binding>\sos_debug\ (K false); fun trace_message ctxt msg = if Config.get ctxt trace orelse Config.get ctxt debug then tracing (msg ()) else (); @@ -218,14 +218,14 @@ (* Conversion from HOL term. *) local - val neg_tm = @{cterm "uminus :: real => _"} - val add_tm = @{cterm "op + :: real => _"} - val sub_tm = @{cterm "op - :: real => _"} - val mul_tm = @{cterm "op * :: real => _"} - val inv_tm = @{cterm "inverse :: real => _"} - val div_tm = @{cterm "op / :: real => _"} - val pow_tm = @{cterm "op ^ :: real => _"} - val zero_tm = @{cterm "0:: real"} + val neg_tm = \<^cterm>\uminus :: real \ _\ + val add_tm = \<^cterm>\op + :: real \ _\ + val sub_tm = \<^cterm>\op - :: real \ _\ + val mul_tm = \<^cterm>\op * :: real \ _\ + val inv_tm = \<^cterm>\inverse :: real \ _\ + val div_tm = \<^cterm>\op / :: real \ _\ + val pow_tm = \<^cterm>\op ^ :: real \ _\ + val zero_tm = \<^cterm>\0:: real\ val is_numeral = can (HOLogic.dest_number o Thm.term_of) fun poly_of_term tm = if tm aconvc zero_tm then poly_0 @@ -270,7 +270,7 @@ end handle CTERM ("dest_comb",_) => poly_var tm) in val poly_of_term = fn tm => - if type_of (Thm.term_of tm) = @{typ real} + if type_of (Thm.term_of tm) = \<^typ>\real\ then poly_of_term tm else error "poly_of_term: term does not have real type" end; @@ -757,7 +757,7 @@ let val {add = _, mul = _, neg = _, pow = _, sub = _, main = real_poly_conv} = Semiring_Normalizer.semiring_normalizers_ord_wrapper ctxt - (the (Semiring_Normalizer.match ctxt @{cterm "(0::real) + 1"})) + (the (Semiring_Normalizer.match ctxt \<^cterm>\(0::real) + 1\)) simple_cterm_ord fun mainf cert_choice translator (eqs, les, lts) = let @@ -861,15 +861,15 @@ by (atomize (full)) (simp add: field_simps)}) fun substitutable_monomial fvs tm = (case Thm.term_of tm of - Free (_, @{typ real}) => + Free (_, \<^typ>\real\) => if not (member (op aconvc) fvs tm) then (@1, tm) else raise Failure "substitutable_monomial" - | @{term "op * :: real => _"} $ _ $ (Free _) => + | \<^term>\op * :: real \ _\ $ _ $ (Free _) => if RealArith.is_ratconst (Thm.dest_arg1 tm) andalso not (member (op aconvc) fvs (Thm.dest_arg tm)) then (RealArith.dest_ratconst (Thm.dest_arg1 tm), Thm.dest_arg tm) else raise Failure "substitutable_monomial" - | @{term "op + :: real => _"}$_$_ => + | \<^term>\op + :: real \ _\$_$_ => (substitutable_monomial (Drule.cterm_add_frees (Thm.dest_arg tm) fvs) (Thm.dest_arg1 tm) handle Failure _ => substitutable_monomial (Drule.cterm_add_frees (Thm.dest_arg1 tm) fvs) (Thm.dest_arg tm)) @@ -882,7 +882,7 @@ if v aconvc w then th else (case Thm.term_of w of - @{term "op + :: real => _"} $ _ $ _ => + \<^term>\op + :: real \ _\ $ _ $ _ => if Thm.dest_arg1 w aconvc v then shuffle2 th else isolate_variable v (shuffle1 th) | _ => error "isolate variable : This should not happen?") @@ -893,7 +893,7 @@ let val {add = _, mul = real_poly_mul_conv, neg = _, pow = _, sub = _, main = real_poly_conv} = Semiring_Normalizer.semiring_normalizers_ord_wrapper ctxt - (the (Semiring_Normalizer.match ctxt @{cterm "(0::real) + 1"})) + (the (Semiring_Normalizer.match ctxt \<^cterm>\(0::real) + 1\)) simple_cterm_ord fun make_substitution th = @@ -901,14 +901,14 @@ val (c,v) = substitutable_monomial [] (Thm.dest_arg1(concl th)) val th1 = Drule.arg_cong_rule - (Thm.apply @{cterm "op * :: real => _"} (RealArith.cterm_of_rat (Rat.inv c))) + (Thm.apply \<^cterm>\op * :: real \ _\ (RealArith.cterm_of_rat (Rat.inv c))) (mk_meta_eq th) val th2 = fconv_rule (binop_conv (real_poly_mul_conv ctxt)) th1 in fconv_rule (arg_conv (real_poly_conv ctxt)) (isolate_variable v th2) end fun oprconv cv ct = let val g = Thm.dest_fun2 ct in - if g aconvc @{cterm "op <= :: real => _"} orelse g aconvc @{cterm "op < :: real => _"} + if g aconvc \<^cterm>\op \ :: real \ _\ orelse g aconvc \<^cterm>\op < :: real \ _\ then arg_conv cv ct else arg1_conv cv ct end fun mainf cert_choice translator = @@ -921,7 +921,7 @@ in substfirst (filter_out - (fn t => (Thm.dest_arg1 o Thm.dest_arg o Thm.cprop_of) t aconvc @{cterm "0::real"}) + (fn t => (Thm.dest_arg1 o Thm.dest_arg o Thm.cprop_of) t aconvc \<^cterm>\0::real\) (map modify eqs), map modify les, map modify lts) @@ -938,21 +938,21 @@ end; val known_sos_constants = - [@{term "op ==>"}, @{term "Trueprop"}, - @{term HOL.False}, @{term HOL.implies}, @{term HOL.conj}, @{term HOL.disj}, - @{term "Not"}, @{term "op = :: bool => _"}, - @{term "All :: (real => _) => _"}, @{term "Ex :: (real => _) => _"}, - @{term "op = :: real => _"}, @{term "op < :: real => _"}, - @{term "op <= :: real => _"}, - @{term "op + :: real => _"}, @{term "op - :: real => _"}, - @{term "op * :: real => _"}, @{term "uminus :: real => _"}, - @{term "op / :: real => _"}, @{term "inverse :: real => _"}, - @{term "op ^ :: real => _"}, @{term "abs :: real => _"}, - @{term "min :: real => _"}, @{term "max :: real => _"}, - @{term "0::real"}, @{term "1::real"}, - @{term "numeral :: num => nat"}, - @{term "numeral :: num => real"}, - @{term "Num.Bit0"}, @{term "Num.Bit1"}, @{term "Num.One"}]; + [\<^term>\op \\, \<^term>\Trueprop\, + \<^term>\HOL.False\, \<^term>\HOL.implies\, \<^term>\HOL.conj\, \<^term>\HOL.disj\, + \<^term>\Not\, \<^term>\op = :: bool \ _\, + \<^term>\All :: (real \ _) \ _\, \<^term>\Ex :: (real \ _) \ _\, + \<^term>\op = :: real \ _\, \<^term>\op < :: real \ _\, + \<^term>\op \ :: real \ _\, + \<^term>\op + :: real \ _\, \<^term>\op - :: real \ _\, + \<^term>\op * :: real \ _\, \<^term>\uminus :: real \ _\, + \<^term>\op / :: real \ _\, \<^term>\inverse :: real \ _\, + \<^term>\op ^ :: real \ _\, \<^term>\abs :: real \ _\, + \<^term>\min :: real \ _\, \<^term>\max :: real \ _\, + \<^term>\0::real\, \<^term>\1::real\, + \<^term>\numeral :: num \ nat\, + \<^term>\numeral :: num \ real\, + \<^term>\Num.Bit0\, \<^term>\Num.Bit1\, \<^term>\Num.One\]; fun check_sos kcts ct = let @@ -963,12 +963,12 @@ else () val fs = Term.add_frees t [] val _ = - if exists (fn ((_,T)) => not (T = @{typ "real"})) fs + if exists (fn ((_,T)) => not (T = \<^typ>\real\)) fs then error "SOS: not sos. Variables with type not real" else () val vs = Term.add_vars t [] val _ = - if exists (fn ((_,T)) => not (T = @{typ "real"})) vs + if exists (fn ((_,T)) => not (T = \<^typ>\real\)) vs then error "SOS: not sos. Variables with type not real" else () val ukcs = subtract (fn (t,p) => Const p aconv t) kcts (Term.add_consts t []) @@ -996,13 +996,13 @@ in fun get_denom b ct = (case Thm.term_of ct of - @{term "op / :: real => _"} $ _ $ _ => + \<^term>\op / :: real \ _\ $ _ $ _ => if is_numeral (Thm.dest_arg ct) then get_denom b (Thm.dest_arg1 ct) else default_SOME (get_denom b) (get_denom b (Thm.dest_arg ct)) (Thm.dest_arg ct, b) - | @{term "op < :: real => _"} $ _ $ _ => + | \<^term>\op < :: real \ _\ $ _ $ _ => lift_SOME (get_denom true) (get_denom true (Thm.dest_arg ct)) (Thm.dest_arg1 ct) - | @{term "op <= :: real => _"} $ _ $ _ => + | \<^term>\op \ :: real \ _\ $ _ $ _ => lift_SOME (get_denom true) (get_denom true (Thm.dest_arg ct)) (Thm.dest_arg1 ct) | _ $ _ => lift_SOME (get_denom b) (get_denom b (Thm.dest_fun ct)) (Thm.dest_arg ct) | _ => NONE) diff -r f18c774acde4 -r 48ef58c6cf4c src/HOL/Library/positivstellensatz.ML --- a/src/HOL/Library/positivstellensatz.ML Fri Dec 22 23:38:54 2017 +0000 +++ b/src/HOL/Library/positivstellensatz.ML Sat Dec 23 19:02:11 2017 +0100 @@ -370,7 +370,7 @@ fun eqT_elim th = Thm.equal_elim (Thm.symmetric th) @{thm TrueI} fun oprconv cv ct = let val g = Thm.dest_fun2 ct - in if g aconvc \<^cterm>\(op <=) :: real \ _\ + in if g aconvc \<^cterm>\(op \) :: real \ _\ orelse g aconvc \<^cterm>\(op <) :: real \ _\ then arg_conv cv ct else arg1_conv cv ct end @@ -409,7 +409,7 @@ (Thm.apply (Thm.apply \<^cterm>\(op =)::real \ _\ (mk_numeric x)) \<^cterm>\0::real\))) | Rational_le x => eqT_elim(numeric_ge_conv(Thm.apply \<^cterm>\Trueprop\ - (Thm.apply (Thm.apply \<^cterm>\(op <=)::real \ _\ + (Thm.apply (Thm.apply \<^cterm>\(op \)::real \ _\ \<^cterm>\0::real\) (mk_numeric x)))) | Rational_lt x => eqT_elim(numeric_gt_conv(Thm.apply \<^cterm>\Trueprop\ (Thm.apply (Thm.apply \<^cterm>\(op <)::real \ _\ \<^cterm>\0::real\) @@ -429,7 +429,7 @@ val concl = Thm.dest_arg o Thm.cprop_of fun is_binop opr ct = (Thm.dest_fun2 ct aconvc opr handle CTERM _ => false) val is_req = is_binop \<^cterm>\(op =):: real \ _\ - val is_ge = is_binop \<^cterm>\(op <=):: real \ _\ + val is_ge = is_binop \<^cterm>\(op \):: real \ _\ val is_gt = is_binop \<^cterm>\(op <):: real \ _\ val is_conj = is_binop \<^cterm>\HOL.conj\ val is_disj = is_binop \<^cterm>\HOL.disj\ diff -r f18c774acde4 -r 48ef58c6cf4c src/HOL/ex/SOS.thy --- a/src/HOL/ex/SOS.thy Fri Dec 22 23:38:54 2017 +0000 +++ b/src/HOL/ex/SOS.thy Sat Dec 23 19:02:11 2017 +0100 @@ -9,14 +9,14 @@ imports "HOL-Library.Sum_of_Squares" begin -lemma "(3::real) * x + 7 * a < 4 & 3 < 2 * x \ a < 0" +lemma "(3::real) * x + 7 * a < 4 \ 3 < 2 * x \ a < 0" by sos lemma "a1 \ 0 \ a2 \ 0 \ (a1 * a1 + a2 * a2 = b1 * b1 + b2 * b2 + 2) \ (a1 * b1 + a2 * b2 = 0) \ a1 * a2 - b1 * b2 \ (0::real)" by sos -lemma "(3::real) * x + 7 * a < 4 & 3 < 2 * x \ a < 0" +lemma "(3::real) * x + 7 * a < 4 \ 3 < 2 * x \ a < 0" by sos lemma "(0::real) \ x \ x \ 1 \ 0 \ y \ y \ 1 \ @@ -120,7 +120,7 @@ lemma "(0::real) \ b \ 0 \ c \ 0 \ x \ 0 \ y \ x\<^sup>2 = c \ y\<^sup>2 = a\<^sup>2 * c + b \ a * c \ y * x" by sos -lemma "\x - z\ \ e \ \y - z\ \ e \ 0 \ u \ 0 \ v \ u + v = 1 --> \(u * x + v * y) - z\ \ (e::real)" +lemma "\x - z\ \ e \ \y - z\ \ e \ 0 \ u \ 0 \ v \ u + v = 1 \ \(u * x + v * y) - z\ \ (e::real)" by sos lemma "(x::real) - y - 2 * x^4 = 0 \ 0 \ x \ x \ 2 \ 0 \ y \ y \ 3 \ y\<^sup>2 - 7 * y - 12 * x + 17 \ 0"