# HG changeset patch # User wenzelm # Date 1635505491 -7200 # Node ID 9b1d33c7bbccaceb4abe7bcfc26c7b0dbe86b254 # Parent 9568db8f48828517fb211e2a1dd879ef42e97fdb clarified antiquotations; diff -r 9568db8f4882 -r 9b1d33c7bbcc src/HOL/Library/Sum_of_Squares/positivstellensatz.ML --- a/src/HOL/Library/Sum_of_Squares/positivstellensatz.ML Fri Oct 29 12:42:06 2021 +0200 +++ b/src/HOL/Library/Sum_of_Squares/positivstellensatz.ML Fri Oct 29 13:04:51 2021 +0200 @@ -315,9 +315,6 @@ fun is_comb t = (case Thm.term_of t of _ $ _ => true | _ => false); -fun is_binop ct ct' = ct aconvc (Thm.dest_fun (Thm.dest_fun ct')) - handle CTERM _ => false; - (* Map back polynomials to HOL. *) @@ -550,21 +547,21 @@ | _ => (acc,t) in fn t => h ([],t) end - - fun f ct = + in + fn A => let val nnf_norm_conv' = nnf_conv ctxt then_conv - literals_conv [\<^term>\HOL.conj\, \<^term>\HOL.disj\] [] + literals_conv [\<^Const>\conj\, \<^Const>\disj\] [] (Conv.cache_conv (first_conv [real_lt_conv, real_le_conv, real_eq_conv, real_not_lt_conv, real_not_le_conv, real_not_eq_conv, all_conv])) - fun absremover ct = (literals_conv [\<^term>\HOL.conj\, \<^term>\HOL.disj\] [] + fun absremover ct = (literals_conv [\<^Const>\conj\, \<^Const>\disj\] [] (try_conv (absconv1 then_conv binop_conv (arg_conv poly_conv))) then_conv try_conv (absconv2 then_conv nnf_norm_conv' then_conv binop_conv absremover)) ct - val nct = \<^instantiate>\A = ct in cprop \\ A\\ - val th0 = (init_conv then_conv arg_conv nnf_norm_conv') nct + val not_A = \<^instantiate>\A in cprop \\ A\\ + val th0 = (init_conv then_conv arg_conv nnf_norm_conv') not_A val tm0 = Thm.dest_arg (Thm.rhs_of th0) val (th, certificates) = if tm0 aconvc \<^cterm>\False\ then (equal_implies_1_rule th0, Trivial) else @@ -576,13 +573,12 @@ val th3 = fold simple_choose evs (prove_hyp (Thm.equal_elim th1 (Thm.assume (Thm.apply \<^cterm>\Trueprop\ bod))) th2) - in (Drule.implies_intr_hyps (prove_hyp (Thm.equal_elim th0 (Thm.assume nct)) th3), certs) + in (Drule.implies_intr_hyps (prove_hyp (Thm.equal_elim th0 (Thm.assume not_A)) th3), certs) end in - (Thm.implies_elim \<^instantiate>\A = ct in lemma \(\ A \ False) \ A\ by blast\ th, + (Thm.implies_elim \<^instantiate>\A in lemma \(\ A \ False) \ A\ by blast\ th, certificates) end - in f end; (* A linear arithmetic prover *) diff -r 9568db8f4882 -r 9b1d33c7bbcc src/HOL/Library/Sum_of_Squares/positivstellensatz_tools.ML --- a/src/HOL/Library/Sum_of_Squares/positivstellensatz_tools.ML Fri Oct 29 12:42:06 2021 +0200 +++ b/src/HOL/Library/Sum_of_Squares/positivstellensatz_tools.ML Fri Oct 29 13:04:51 2021 +0200 @@ -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, \<^Type>\real\)), k)) fun parse_monomial ctxt = repeat_sep "*" (parse_varpow ctxt) >> (fn xs => fold FuncUtil.Ctermfunc.update xs FuncUtil.Ctermfunc.empty) diff -r 9568db8f4882 -r 9b1d33c7bbcc src/HOL/Library/Sum_of_Squares/sum_of_squares.ML --- a/src/HOL/Library/Sum_of_Squares/sum_of_squares.ML Fri Oct 29 12:42:06 2021 +0200 +++ b/src/HOL/Library/Sum_of_Squares/sum_of_squares.ML Fri Oct 29 13:04:51 2021 +0200 @@ -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) = \<^Type>\real\ then poly_of_term tm else error "poly_of_term: term does not have real type" end; @@ -852,22 +852,22 @@ open Conv val concl = Thm.dest_arg o Thm.cprop_of val shuffle1 = - fconv_rule (rewr_conv @{lemma "(a + x == y) == (x == y - (a::real))" + fconv_rule (rewr_conv @{lemma "(a + x \ y) \ (x \ y - a)" for a x y :: real by (atomize (full)) (simp add: field_simps)}) val shuffle2 = - fconv_rule (rewr_conv @{lemma "(x + a == y) == (x == y - (a::real))" + fconv_rule (rewr_conv @{lemma "(x + a \ y) \ (x \ y - a)" for a x y :: real by (atomize (full)) (simp add: field_simps)}) fun substitutable_monomial fvs tm = (case Thm.term_of tm of - Free (_, \<^typ>\real\) => + Free (_, \<^Type>\real\) => if not (Cterms.defined fvs tm) then (@1, tm) else raise Failure "substitutable_monomial" - | \<^term>\(*) :: real \ _\ $ _ $ (Free _) => + | \<^Const_>\times \<^typ>\real\ for _ \Free _\\ => if RealArith.is_ratconst (Thm.dest_arg1 tm) andalso not (Cterms.defined fvs (Thm.dest_arg tm)) then (RealArith.dest_ratconst (Thm.dest_arg1 tm), Thm.dest_arg tm) else raise Failure "substitutable_monomial" - | \<^term>\(+) :: real \ _\$_$_ => + | \<^Const_>\plus \<^Type>\real\ for _ _\ => (substitutable_monomial (Drule.add_frees_cterm (Thm.dest_arg tm) fvs) (Thm.dest_arg1 tm) handle Failure _ => @@ -882,7 +882,7 @@ if v aconvc w then th else (case Thm.term_of w of - \<^term>\(+) :: real \ _\ $ _ $ _ => + \<^Const_>\plus \<^Type>\real\ for _ _\ => if Thm.dest_arg1 w aconvc v then shuffle2 th else isolate_variable v (shuffle1 th) | _ => error "isolate variable : This should not happen?") @@ -938,21 +938,21 @@ end; val known_sos_constants = - [\<^term>\(\)\, \<^term>\Trueprop\, - \<^term>\HOL.False\, \<^term>\HOL.implies\, \<^term>\HOL.conj\, \<^term>\HOL.disj\, - \<^term>\Not\, \<^term>\(=) :: bool \ _\, - \<^term>\All :: (real \ _) \ _\, \<^term>\Ex :: (real \ _) \ _\, - \<^term>\(=) :: real \ _\, \<^term>\(<) :: real \ _\, - \<^term>\(\) :: real \ _\, - \<^term>\(+) :: real \ _\, \<^term>\(-) :: real \ _\, - \<^term>\(*) :: real \ _\, \<^term>\uminus :: real \ _\, - \<^term>\(/) :: real \ _\, \<^term>\inverse :: real \ _\, - \<^term>\(^) :: 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\]; + [\<^Const>\Pure.imp\, \<^Const>\Trueprop\, + \<^Const>\False\, \<^Const>\implies\, \<^Const>\conj\, \<^Const>\disj\, + \<^Const>\Not\, \<^Const>\HOL.eq \<^Type>\bool\\, + \<^Const>\All \<^Type>\real\\, \<^Const>\Ex \<^Type>\real\\, + \<^Const>\HOL.eq \<^Type>\real\\, \<^Const>\less \<^Type>\real\\, + \<^Const>\less_eq \<^Type>\real\\, + \<^Const>\plus \<^Type>\real\\, \<^Const>\minus \<^Type>\real\\, + \<^Const>\times \<^Type>\real\\, \<^Const>\uminus \<^Type>\real\\, + \<^Const>\divide \<^Type>\real\\, \<^Const>\inverse \<^Type>\real\\, + \<^Const>\power \<^Type>\real\\, \<^Const>\abs \<^Type>\real\\, + \<^Const>\min \<^Type>\real\\, \<^Const>\max \<^Type>\real\\, + \<^Const>\zero_class.zero \<^Type>\real\\, \<^Const>\one_class.one \<^Type>\real\\, + \<^Const>\numeral \<^Type>\nat\\, + \<^Const>\numeral \<^Type>\real\\, + \<^Const>\Num.Bit0\, \<^Const>\Num.Bit1\, \<^Const>\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)) => T <> \<^Type>\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)) => T <> \<^Type>\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>\(/) :: real \ _\ $ _ $ _ => + \<^Const_>\divide \<^Type>\real\ for _ _\ => 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>\(<) :: real \ _\ $ _ $ _ => + | \<^Const_>\less \<^Type>\real\ for _ _\ => lift_SOME (get_denom true) (get_denom true (Thm.dest_arg ct)) (Thm.dest_arg1 ct) - | \<^term>\(\) :: real \ _\ $ _ $ _ => + | \<^Const_>\less_eq \<^Type>\real\ for _ _\ => 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)