src/HOL/ex/ApproximationEx.thy
author blanchet
Wed, 04 Mar 2009 10:45:52 +0100
changeset 30240 5b25fee0362c
parent 29805 a5da150bd0ab
child 30413 c41afa5607be
permissions -rw-r--r--
Merge.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30240
blanchet
parents: 29805
diff changeset
     1
(*  Title:      HOL/ex/ApproximationEx.thy
blanchet
parents: 29805
diff changeset
     2
    Author:     Johannes Hoelzl <hoelzl@in.tum.de> 2009
29805
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
     3
*)
30240
blanchet
parents: 29805
diff changeset
     4
29805
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
     5
theory ApproximationEx
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
     6
imports "~~/src/HOL/Reflection/Approximation"
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
     7
begin
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
     8
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
     9
text {*
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    10
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    11
Here are some examples how to use the approximation method.
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    12
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    13
The parameter passed to the method specifies the precision used by the computations, it is specified
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    14
as number of bits to calculate. When a variable is used it needs to be bounded by an interval. This
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    15
interval is specified as a conjunction of the lower and upper bound. It must have the form
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    16
@{text "\<lbrakk> l\<^isub>1 \<le> x\<^isub>1 \<and> x\<^isub>1 \<le> u\<^isub>1 ; \<dots> ; l\<^isub>n \<le> x\<^isub>n \<and> x\<^isub>n \<le> u\<^isub>n \<rbrakk> \<Longrightarrow> F"} where @{term F} is the formula, and
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    17
@{text "x\<^isub>1, \<dots>, x\<^isub>n"} are the variables. The lower bounds @{text "l\<^isub>1, \<dots>, l\<^isub>n"} and the upper bounds
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    18
@{text "u\<^isub>1, \<dots>, u\<^isub>n"} must either be integer numerals, floating point numbers or of the form
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    19
@{term "m * pow2 e"} to specify a exact floating point value.
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    20
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    21
*}
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    22
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    23
section "Compute some transcendental values"
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    24
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    25
lemma "\<bar> ln 2 - 544531980202654583340825686620847 / 785593587443817081832229725798400 \<bar> < inverse (2^51) "
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    26
  by (approximation 80)
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    27
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    28
lemma "\<bar> exp 1.626 - 5.083499996273 \<bar> < (inverse 10 ^ 10 :: real)"
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    29
  by (approximation 80)
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    30
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    31
lemma "\<bar> sqrt 2 - 1.4142135623730951 \<bar> < inverse 10 ^ 16"
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    32
  by (approximation 80)
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    33
   
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    34
lemma "\<bar> pi - 3.1415926535897932385 \<bar> < inverse 10 ^ 18"
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    35
  by (approximation 80)
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    36
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    37
section "Use variable ranges"
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    38
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    39
lemma "0.5 \<le> x \<and> x \<le> 4.5 \<Longrightarrow> \<bar> arctan x - 0.91 \<bar> < 0.455"
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    40
  by (approximation 10)
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    41
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    42
lemma "0 \<le> x \<and> x \<le> 1 \<Longrightarrow> 0 \<le> sin x"
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    43
  by (approximation 10)
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    44
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    45
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    46
end
a5da150bd0ab Add approximation method
hoelzl
parents:
diff changeset
    47