src/HOL/Library/Sum_Of_Squares.thy
author haftmann
Wed, 23 Sep 2009 14:00:12 +0200
changeset 32657 5f13912245ff
parent 32645 1cc5b24f5a01
child 32949 aa6c470a962a
permissions -rw-r--r--
Code_Eval(uation)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32333
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
     1
(* Title:      HOL/Library/Sum_Of_Squares.thy
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
     2
   Author:     Amine Chaieb, University of Cambridge
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
     3
*)
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
     4
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
     5
header {* A decision method for universal multivariate real arithmetic with addition, 
32333
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
     6
  multiplication and ordering using semidefinite programming *}
32271
378ebd64447d sos comments modified
nipkow
parents: 32268
diff changeset
     7
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
     8
theory Sum_Of_Squares
32332
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
     9
imports Complex_Main (* "~~/src/HOL/Decision_Procs/Dense_Linear_Order" *)
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
    10
uses
32333
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    11
  ("positivstellensatz.ML")  (* duplicate use!? -- cf. Euclidian_Space.thy *)
32332
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
    12
  ("Sum_Of_Squares/sum_of_squares.ML")
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    13
  ("Sum_Of_Squares/positivstellensatz_tools.ML")
32332
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
    14
  ("Sum_Of_Squares/sos_wrapper.ML")
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
    15
begin
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    16
32333
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    17
text {*
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    18
  In order to use the method sos, call it with @{text "(sos
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    19
  remote_csdp)"} to use the remote solver.  Or install CSDP
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    20
  (https://projects.coin-or.org/Csdp), configure the Isabelle setting
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    21
  @{text CSDP_EXE}, and call it with @{text "(sos csdp)"}.  By
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    22
  default, sos calls @{text remote_csdp}.  This can take of the order
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    23
  of a minute for one sos call, because sos calls CSDP repeatedly.  If
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    24
  you install CSDP locally, sos calls typically takes only a few
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    25
  seconds.
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    26
  sos generates a certificate which can be used to repeat the proof
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    27
  without calling an external prover.
32333
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    28
*}
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    29
d4cb904cc63c tuned header;
wenzelm
parents: 32332
diff changeset
    30
text {* setup sos tactic *}
32332
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
    31
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
    32
use "positivstellensatz.ML"
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    33
use "Sum_Of_Squares/positivstellensatz_tools.ML"
32332
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
    34
use "Sum_Of_Squares/sum_of_squares.ML"
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
    35
use "Sum_Of_Squares/sos_wrapper.ML"
bc5cec7b2be6 misc changes to SOS by Philipp Meyer:
wenzelm
parents: 32271
diff changeset
    36
32268
d50f0cb67578 Functionality for sum of squares to call a remote csdp prover
Philipp Meyer
parents: 31512
diff changeset
    37
setup SosWrapper.setup
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    38
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    39
text {* Tests *}
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    40
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    41
lemma "(3::real) * x + 7 * a < 4 & 3 < 2 * x \<Longrightarrow> a < 0"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    42
by (sos_cert "((R<1 + (((A<1 * R<1) * (R<2 * [1]^2)) + (((A<0 * R<1) * (R<3 * [1]^2)) + ((A<=0 * R<1) * (R<14 * [1]^2))))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    43
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    44
lemma "a1 >= 0 & a2 >= 0 \<and> (a1 * a1 + a2 * a2 = b1 * b1 + b2 * b2 + 2) \<and> (a1 * b1 + a2 * b2 = 0) --> a1 * a2 - b1 * b2 >= (0::real)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    45
by (sos_cert "(((A<0 * R<1) + (([~1/2*a1*b2 + ~1/2*a2*b1] * A=0) + (([~1/2*a1*a2 + 1/2*b1*b2] * A=1) + (((A<0 * R<1) * ((R<1/2 * [b2]^2) + (R<1/2 * [b1]^2))) + ((A<=0 * (A<=1 * R<1)) * ((R<1/2 * [b2]^2) + ((R<1/2 * [b1]^2) + ((R<1/2 * [a2]^2) + (R<1/2 * [a1]^2))))))))))")
32268
d50f0cb67578 Functionality for sum of squares to call a remote csdp prover
Philipp Meyer
parents: 31512
diff changeset
    46
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    47
lemma "(3::real) * x + 7 * a < 4 & 3 < 2 * x --> a < 0"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    48
by (sos_cert "((R<1 + (((A<1 * R<1) * (R<2 * [1]^2)) + (((A<0 * R<1) * (R<3 * [1]^2)) + ((A<=0 * R<1) * (R<14 * [1]^2))))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    49
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    50
lemma "(0::real) <= x & x <= 1 & 0 <= y & y <= 1  --> x^2 + y^2 < 1 |(x - 1)^2 + y^2 < 1 | x^2 + (y - 1)^2 < 1 | (x - 1)^2 + (y - 1)^2 < 1"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    51
by (sos_cert "((R<1 + (((A<=3 * (A<=4 * R<1)) * (R<1 * [1]^2)) + (((A<=2 * (A<=7 * R<1)) * (R<1 * [1]^2)) + (((A<=1 * (A<=6 * R<1)) * (R<1 * [1]^2)) + ((A<=0 * (A<=5 * R<1)) * (R<1 * [1]^2)))))))")
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    52
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    53
lemma "(0::real) <= x & 0 <= y & 0 <= z & x + y + z <= 3 --> x * y + x * z + y * z >= 3 * x * y * z"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    54
by (sos_cert "(((A<0 * R<1) + (((A<0 * R<1) * (R<1/2 * [1]^2)) + (((A<=2 * R<1) * (R<1/2 * [~1*x + y]^2)) + (((A<=1 * R<1) * (R<1/2 * [~1*x + z]^2)) + (((A<=1 * (A<=2 * (A<=3 * R<1))) * (R<1/2 * [1]^2)) + (((A<=0 * R<1) * (R<1/2 * [~1*y + z]^2)) + (((A<=0 * (A<=2 * (A<=3 * R<1))) * (R<1/2 * [1]^2)) + ((A<=0 * (A<=1 * (A<=3 * R<1))) * (R<1/2 * [1]^2))))))))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    55
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    56
lemma "((x::real)^2 + y^2 + z^2 = 1) --> (x + y + z)^2 <= 3"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    57
by (sos_cert "(((A<0 * R<1) + (([~3] * A=0) + (R<1 * ((R<2 * [~1/2*x + ~1/2*y + z]^2) + (R<3/2 * [~1*x + y]^2))))))")
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    58
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    59
lemma "(w^2 + x^2 + y^2 + z^2 = 1) --> (w + x + y + z)^2 <= (4::real)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    60
by (sos_cert "(((A<0 * R<1) + (([~4] * A=0) + (R<1 * ((R<3 * [~1/3*w + ~1/3*x + ~1/3*y + z]^2) + ((R<8/3 * [~1/2*w + ~1/2*x + y]^2) + (R<2 * [~1*w + x]^2)))))))")
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    61
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    62
lemma "(x::real) >= 1 & y >= 1 --> x * y >= x + y - 1"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    63
by (sos_cert "(((A<0 * R<1) + ((A<=0 * (A<=1 * R<1)) * (R<1 * [1]^2))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    64
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    65
lemma "(x::real) > 1 & y > 1 --> x * y > x + y - 1"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    66
by (sos_cert "((((A<0 * A<1) * R<1) + ((A<=0 * R<1) * (R<1 * [1]^2))))") 
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    67
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    68
lemma "abs(x) <= 1 --> abs(64 * x^7 - 112 * x^5 + 56 * x^3 - 7 * x) <= (1::real)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    69
by (sos_cert "((((A<0 * R<1) + ((A<=1 * R<1) * (R<1 * [~8*x^3 + ~4*x^2 + 4*x + 1]^2)))) & ((((A<0 * A<1) * R<1) + ((A<=1 * (A<0 * R<1)) * (R<1 * [8*x^3 + ~4*x^2 + ~4*x + 1]^2)))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    70
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    71
(* ------------------------------------------------------------------------- *)
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    72
(* One component of denominator in dodecahedral example.                     *)
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    73
(* ------------------------------------------------------------------------- *)
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    74
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    75
lemma "2 <= x & x <= 125841 / 50000 & 2 <= y & y <= 125841 / 50000 & 2 <= z & z <= 125841 / 50000 --> 2 * (x * z + x * y + y * z) - (x * x + y * y + z * z) >= (0::real)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    76
by (sos_cert "(((A<0 * R<1) + ((R<1 * ((R<5749028157/5000000000 * [~25000/222477*x + ~25000/222477*y + ~25000/222477*z + 1]^2) + ((R<864067/1779816 * [419113/864067*x + 419113/864067*y + z]^2) + ((R<320795/864067 * [419113/1283180*x + y]^2) + (R<1702293/5132720 * [x]^2))))) + (((A<=4 * (A<=5 * R<1)) * (R<3/2 * [1]^2)) + (((A<=3 * (A<=5 * R<1)) * (R<1/2 * [1]^2)) + (((A<=2 * (A<=4 * R<1)) * (R<1 * [1]^2)) + (((A<=2 * (A<=3 * R<1)) * (R<3/2 * [1]^2)) + (((A<=1 * (A<=5 * R<1)) * (R<1/2 * [1]^2)) + (((A<=1 * (A<=3 * R<1)) * (R<1/2 * [1]^2)) + (((A<=0 * (A<=4 * R<1)) * (R<1 * [1]^2)) + (((A<=0 * (A<=2 * R<1)) * (R<1 * [1]^2)) + ((A<=0 * (A<=1 * R<1)) * (R<3/2 * [1]^2)))))))))))))")
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    77
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    78
(* ------------------------------------------------------------------------- *)
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    79
(* Over a larger but simpler interval.                                       *)
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    80
(* ------------------------------------------------------------------------- *)
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    81
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    82
lemma "(2::real) <= x & x <= 4 & 2 <= y & y <= 4 & 2 <= z & z <= 4 --> 0 <= 2 * (x * z + x * y + y * z) - (x * x + y * y + z * z)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    83
by (sos_cert "((R<1 + ((R<1 * ((R<1 * [~1/6*x + ~1/6*y + ~1/6*z + 1]^2) + ((R<1/18 * [~1/2*x + ~1/2*y + z]^2) + (R<1/24 * [~1*x + y]^2)))) + (((A<0 * R<1) * (R<1/12 * [1]^2)) + (((A<=4 * (A<=5 * R<1)) * (R<1/6 * [1]^2)) + (((A<=2 * (A<=4 * R<1)) * (R<1/6 * [1]^2)) + (((A<=2 * (A<=3 * R<1)) * (R<1/6 * [1]^2)) + (((A<=0 * (A<=4 * R<1)) * (R<1/6 * [1]^2)) + (((A<=0 * (A<=2 * R<1)) * (R<1/6 * [1]^2)) + ((A<=0 * (A<=1 * R<1)) * (R<1/6 * [1]^2)))))))))))")
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    84
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    85
(* ------------------------------------------------------------------------- *)
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    86
(* We can do 12. I think 12 is a sharp bound; see PP's certificate.          *)
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    87
(* ------------------------------------------------------------------------- *)
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    88
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    89
lemma "2 <= (x::real) & x <= 4 & 2 <= y & y <= 4 & 2 <= z & z <= 4 --> 12 <= 2 * (x * z + x * y + y * z) - (x * x + y * y + z * z)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    90
by (sos_cert "(((A<0 * R<1) + (((A<=4 * R<1) * (R<2/3 * [1]^2)) + (((A<=4 * (A<=5 * R<1)) * (R<1 * [1]^2)) + (((A<=3 * (A<=4 * R<1)) * (R<1/3 * [1]^2)) + (((A<=2 * R<1) * (R<2/3 * [1]^2)) + (((A<=2 * (A<=5 * R<1)) * (R<1/3 * [1]^2)) + (((A<=2 * (A<=4 * R<1)) * (R<8/3 * [1]^2)) + (((A<=2 * (A<=3 * R<1)) * (R<1 * [1]^2)) + (((A<=1 * (A<=4 * R<1)) * (R<1/3 * [1]^2)) + (((A<=1 * (A<=2 * R<1)) * (R<1/3 * [1]^2)) + (((A<=0 * R<1) * (R<2/3 * [1]^2)) + (((A<=0 * (A<=5 * R<1)) * (R<1/3 * [1]^2)) + (((A<=0 * (A<=4 * R<1)) * (R<8/3 * [1]^2)) + (((A<=0 * (A<=3 * R<1)) * (R<1/3 * [1]^2)) + (((A<=0 * (A<=2 * R<1)) * (R<8/3 * [1]^2)) + ((A<=0 * (A<=1 * R<1)) * (R<1 * [1]^2))))))))))))))))))")
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
    91
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    92
(* ------------------------------------------------------------------------- *)
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    93
(* Inequality from sci.math (see "Leon-Sotelo, por favor").                  *)
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    94
(* ------------------------------------------------------------------------- *)
32543
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
    95
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    96
lemma "0 <= (x::real) & 0 <= y & (x * y = 1) --> x + y <= x^2 + y^2"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    97
by (sos_cert "(((A<0 * R<1) + (([1] * A=0) + (R<1 * ((R<1 * [~1/2*x + ~1/2*y + 1]^2) + (R<3/4 * [~1*x + y]^2))))))") 
32543
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
    98
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
    99
lemma "0 <= (x::real) & 0 <= y & (x * y = 1) --> x * y * (x + y) <= x^2 + y^2"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   100
by (sos_cert "(((A<0 * R<1) + (([~1*x + ~1*y + 1] * A=0) + (R<1 * ((R<1 * [~1/2*x + ~1/2*y + 1]^2) + (R<3/4 * [~1*x + y]^2))))))") 
32543
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
   101
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   102
lemma "0 <= (x::real) & 0 <= y --> x * y * (x + y)^2 <= (x^2 + y^2)^2"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   103
by (sos_cert "(((A<0 * R<1) + (R<1 * ((R<1 * [~1/2*x^2 + y^2 + ~1/2*x*y]^2) + (R<3/4 * [~1*x^2 + x*y]^2)))))")
32543
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
   104
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   105
lemma "(0::real) <= a & 0 <= b & 0 <= c & c * (2 * a + b)^3/ 27 <= x \<longrightarrow> c * a^2 * b <= x"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   106
by (sos_cert "(((A<0 * R<1) + (((A<=3 * R<1) * (R<1 * [1]^2)) + (((A<=1 * (A<=2 * R<1)) * (R<1/27 * [~1*a + b]^2)) + ((A<=0 * (A<=2 * R<1)) * (R<8/27 * [~1*a + b]^2))))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   107
 
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   108
lemma "(0::real) < x --> 0 < 1 + x + x^2"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   109
by (sos_cert "((R<1 + ((R<1 * (R<1 * [x]^2)) + (((A<0 * R<1) * (R<1 * [1]^2)) + ((A<=0 * R<1) * (R<1 * [1]^2))))))")
32543
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
   110
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   111
lemma "(0::real) <= x --> 0 < 1 + x + x^2"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   112
by (sos_cert "((R<1 + ((R<1 * (R<1 * [x]^2)) + (((A<=1 * R<1) * (R<1 * [1]^2)) + ((A<=0 * R<1) * (R<1 * [1]^2))))))")
31131
d9752181691a Now deals with division
chaieb
parents: 31119
diff changeset
   113
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   114
lemma "(0::real) < 1 + x^2"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   115
by (sos_cert "((R<1 + ((R<1 * (R<1 * [x]^2)) + ((A<=0 * R<1) * (R<1 * [1]^2)))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   116
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   117
lemma "(0::real) <= 1 + 2 * x + x^2"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   118
by (sos_cert "(((A<0 * R<1) + (R<1 * (R<1 * [x + 1]^2))))")
32543
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
   119
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   120
lemma "(0::real) < 1 + abs x"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   121
by (sos_cert "((R<1 + (((A<=1 * R<1) * (R<1/2 * [1]^2)) + ((A<=0 * R<1) * (R<1/2 * [1]^2)))))")
32543
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
   122
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   123
lemma "(0::real) < 1 + (1 + x)^2 * (abs x)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   124
by (sos_cert "(((R<1 + (((A<=1 * R<1) * (R<1 * [1]^2)) + ((A<=0 * R<1) * (R<1 * [x + 1]^2))))) & ((R<1 + (((A<0 * R<1) * (R<1 * [x + 1]^2)) + ((A<=0 * R<1) * (R<1 * [1]^2))))))")
32543
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
   125
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
   126
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
   127
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   128
lemma "abs ((1::real) + x^2) = (1::real) + x^2"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   129
by (sos_cert "(() & (((R<1 + ((R<1 * (R<1 * [x]^2)) + ((A<1 * R<1) * (R<1/2 * [1]^2))))) & ((R<1 + ((R<1 * (R<1 * [x]^2)) + ((A<0 * R<1) * (R<1 * [1]^2)))))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   130
lemma "(3::real) * x + 7 * a < 4 \<and> 3 < 2 * x \<longrightarrow> a < 0"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   131
by (sos_cert "((R<1 + (((A<1 * R<1) * (R<2 * [1]^2)) + (((A<0 * R<1) * (R<3 * [1]^2)) + ((A<=0 * R<1) * (R<14 * [1]^2))))))")
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
   132
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   133
lemma "(0::real) < x --> 1 < y --> y * x <= z --> x < z"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   134
by (sos_cert "((((A<0 * A<1) * R<1) + (((A<=1 * R<1) * (R<1 * [1]^2)) + ((A<=0 * R<1) * (R<1 * [1]^2)))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   135
lemma "(1::real) < x --> x^2 < y --> 1 < y"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   136
by (sos_cert "((((A<0 * A<1) * R<1) + ((R<1 * ((R<1/10 * [~2*x + y + 1]^2) + (R<1/10 * [~1*x + y]^2))) + (((A<1 * R<1) * (R<1/2 * [1]^2)) + (((A<0 * R<1) * (R<1 * [x]^2)) + (((A<=0 * R<1) * ((R<1/10 * [x + 1]^2) + (R<1/10 * [x]^2))) + (((A<=0 * (A<1 * R<1)) * (R<1/5 * [1]^2)) + ((A<=0 * (A<0 * R<1)) * (R<1/5 * [1]^2)))))))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   137
lemma "(b::real)^2 < 4 * a * c --> ~(a * x^2 + b * x + c = 0)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   138
by (sos_cert "(((A<0 * R<1) + (R<1 * (R<1 * [2*a*x + b]^2))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   139
lemma "(b::real)^2 < 4 * a * c --> ~(a * x^2 + b * x + c = 0)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   140
by (sos_cert "(((A<0 * R<1) + (R<1 * (R<1 * [2*a*x + b]^2))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   141
lemma "((a::real) * x^2 + b * x + c = 0) --> b^2 >= 4 * a * c"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   142
by (sos_cert "(((A<0 * R<1) + (R<1 * (R<1 * [2*a*x + b]^2))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   143
lemma "(0::real) <= b & 0 <= c & 0 <= x & 0 <= y & (x^2 = c) & (y^2 = a^2 * c + b) --> a * c <= y * x"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   144
by (sos_cert "(((A<0 * (A<0 * R<1)) + (((A<=2 * (A<=3 * (A<0 * R<1))) * (R<2 * [1]^2)) + ((A<=0 * (A<=1 * R<1)) * (R<1 * [1]^2)))))")
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   145
lemma "abs(x - z) <= e & abs(y - z) <= e & 0 <= u & 0 <= v & (u + v = 1) --> abs((u * x + v * y) - z) <= (e::real)"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   146
by (sos_cert "((((A<0 * R<1) + (((A<=3 * (A<=6 * R<1)) * (R<1 * [1]^2)) + ((A<=1 * (A<=5 * R<1)) * (R<1 * [1]^2))))) & ((((A<0 * A<1) * R<1) + (((A<=3 * (A<=5 * (A<0 * R<1))) * (R<1 * [1]^2)) + ((A<=1 * (A<=4 * (A<0 * R<1))) * (R<1 * [1]^2))))))")
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
   147
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
   148
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   149
(* lemma "((x::real) - y - 2 * x^4 = 0) & 0 <= x & x <= 2 & 0 <= y & y <= 3 --> y^2 - 7 * y - 12 * x + 17 >= 0" by sos *) (* Too hard?*)
32543
62e6c9b67c6f tuned document -- proper text instead of source comments, reduced line length;
wenzelm
parents: 32333
diff changeset
   150
31131
d9752181691a Now deals with division
chaieb
parents: 31119
diff changeset
   151
lemma "(0::real) <= x --> (1 + x + x^2)/(1 + x^2) <= 1 + x"
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   152
by (sos_cert "(((((A<0 * A<1) * R<1) + ((A<=0 * (A<0 * R<1)) * (R<1 * [x]^2)))) & ((R<1 + ((R<1 * (R<1 * [x]^2)) + ((A<0 * R<1) * (R<1 * [1]^2))))))")
31131
d9752181691a Now deals with division
chaieb
parents: 31119
diff changeset
   153
d9752181691a Now deals with division
chaieb
parents: 31119
diff changeset
   154
lemma "(0::real) <= x --> 1 - x <= 1 / (1 + x + x^2)"
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   155
by (sos_cert "(((R<1 + (([~4/3] * A=0) + ((R<1 * ((R<1/3 * [3/2*x + 1]^2) + (R<7/12 * [x]^2))) + ((A<=0 * R<1) * (R<1/3 * [1]^2)))))) & (((((A<0 * A<1) * R<1) + ((A<=0 * (A<0 * R<1)) * (R<1 * [x]^2)))) & ((R<1 + ((R<1 * (R<1 * [x]^2)) + (((A<0 * R<1) * (R<1 * [1]^2)) + ((A<=0 * R<1) * (R<1 * [1]^2))))))))")
31131
d9752181691a Now deals with division
chaieb
parents: 31119
diff changeset
   156
d9752181691a Now deals with division
chaieb
parents: 31119
diff changeset
   157
lemma "(x::real) <= 1 / 2 --> - x - 2 * x^2 <= - x / (1 - x)"
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   158
by (sos_cert "((((A<0 * A<1) * R<1) + ((A<=0 * (A<0 * R<1)) * (R<1 * [x]^2))))")
31131
d9752181691a Now deals with division
chaieb
parents: 31119
diff changeset
   159
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   160
lemma "4*r^2 = p^2 - 4*q & r >= (0::real) & x^2 + p*x + q = 0 --> 2*(x::real) = - p + 2*r | 2*x = -p - 2*r"
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   161
by (sos_cert "((((((A<0 * A<1) * R<1) + ([~4] * A=0))) & ((((A<0 * A<1) * R<1) + ([4] * A=0)))) & (((((A<0 * A<1) * R<1) + ([4] * A=0))) & ((((A<0 * A<1) * R<1) + ([~4] * A=0)))))")
31119
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
   162
2532bb2d65c7 A decision method for universal multivariate real arithmetic with add
chaieb
parents:
diff changeset
   163
end
32645
1cc5b24f5a01 sos method generates and uses proof certificates
Philipp Meyer
parents: 32543
diff changeset
   164