real.why 7.48 KB
 Jean-Christophe Filliâtre committed Mar 23, 2010 1 2 `````` theory Real `````` MARCHE Claude committed Mar 26, 2010 3 `````` `````` Andrei Paskevich committed May 05, 2010 4 5 6 7 8 9 `````` logic zero : real = 0.0 logic one : real = 1.0 clone export algebra.Field with type t = real, logic zero = zero, logic one = one `````` Andrei Paskevich committed Jun 24, 2010 10 11 12 13 `````` logic (< ) real real logic (<=) (x y : real) = x < y or x = y logic (> ) (x y : real) = y < x logic (>=) (x y : real) = y <= x `````` Jean-Christophe Filliâtre committed Mar 23, 2010 14 `````` `````` Jean-Christophe Filliâtre committed Apr 14, 2010 15 16 `````` clone export relations.TotalOrder with type t = real, logic rel = (<=) `````` Jean-Christophe Filliâtre committed Mar 23, 2010 17 18 19 20 21 22 23 `````` end theory Abs use import Real `````` Jean-Christophe Filliâtre committed May 05, 2010 24 `````` logic abs(x : real) : real = if x >= 0.0 then x else -x `````` Jean-Christophe Filliâtre committed Mar 23, 2010 25 `````` `````` Andrei Paskevich committed Jun 21, 2010 26 `````` lemma Abs_le: forall x y:real. abs x <= y <-> -y <= x <= y `````` MARCHE Claude committed Mar 25, 2010 27 `````` `````` Andrei Paskevich committed Jun 21, 2010 28 `````` lemma Abs_pos: forall x:real. abs x >= 0.0 `````` MARCHE Claude committed Mar 26, 2010 29 `````` `````` Jean-Christophe Filliâtre committed Mar 23, 2010 30 31 32 33 34 35 ``````end theory MinMax use import Real `````` Andrei Paskevich committed Jun 24, 2010 36 37 `````` logic min real real : real logic max real real : real `````` Jean-Christophe Filliâtre committed Mar 23, 2010 38 `````` `````` Andrei Paskevich committed Jun 21, 2010 39 40 41 42 `````` axiom Max_is_ge : forall x y:real. max x y >= x and max x y >= y axiom Max_is_some : forall x y:real. max x y = x or max x y = y axiom Min_is_le : forall x y:real. min x y <= x and min x y <= y axiom Min_is_some : forall x y:real. min x y = x or min x y = y `````` Jean-Christophe Filliâtre committed Mar 23, 2010 43 44 45 46 47 48 49 50 `````` end theory FromInt use int.Int use import Real `````` Andrei Paskevich committed Jun 24, 2010 51 `````` logic from_int int : real `````` Jean-Christophe Filliâtre committed Mar 23, 2010 52 `````` `````` Andrei Paskevich committed Jun 21, 2010 53 54 `````` axiom Zero: from_int 0 = 0.0 axiom One: from_int 1 = 1.0 `````` Jean-Christophe Filliâtre committed Mar 23, 2010 55 56 `````` axiom Add: `````` Andrei Paskevich committed Jun 21, 2010 57 `````` forall x y:int. from_int (Int.(+) x y) = from_int x + from_int y `````` Jean-Christophe Filliâtre committed Mar 23, 2010 58 `````` axiom Sub: `````` Andrei Paskevich committed Jun 21, 2010 59 `````` forall x y:int. from_int (Int.(-) x y) = from_int x - from_int y `````` Jean-Christophe Filliâtre committed Mar 23, 2010 60 `````` axiom Mul: `````` Andrei Paskevich committed Jun 21, 2010 61 `````` forall x y:int. from_int (Int.(*) x y) = from_int x * from_int y `````` Jean-Christophe Filliâtre committed Mar 23, 2010 62 `````` axiom Neg: `````` Andrei Paskevich committed Jun 21, 2010 63 `````` forall x y:int. from_int (Int.(-_) (x)) = - from_int x `````` Jean-Christophe Filliâtre committed Mar 23, 2010 64 `````` `````` MARCHE Claude committed Mar 26, 2010 65 66 67 68 69 70 ``````end theory FromIntTest use import FromInt `````` Andrei Paskevich committed Jun 21, 2010 71 `````` lemma Test1: from_int 2 = 2.0 `````` MARCHE Claude committed Mar 26, 2010 72 `````` `````` Jean-Christophe Filliâtre committed Mar 23, 2010 73 74 75 76 ``````end theory Truncate `````` MARCHE Claude committed Mar 26, 2010 77 78 79 80 81 `````` use import Real use import FromInt (* truncate: rounds towards zero *) `````` Andrei Paskevich committed Jun 24, 2010 82 `````` logic truncate real : int `````` MARCHE Claude committed Mar 26, 2010 83 84 `````` axiom Truncate_int : `````` Andrei Paskevich committed Jun 21, 2010 85 `````` forall i:int. truncate (from_int i) = i `````` MARCHE Claude committed Mar 26, 2010 86 87 88 `````` axiom Truncate_down_pos: forall x:real. x >= 0.0 -> `````` Andrei Paskevich committed Jun 21, 2010 89 `````` from_int (truncate x) <= x < from_int (Int.(+) (truncate x) 1) `````` MARCHE Claude committed Mar 26, 2010 90 91 92 `````` axiom Truncate_up_neg: forall x:real. x <= 0.0 -> `````` Andrei Paskevich committed Jun 21, 2010 93 `````` from_int (Int.(-) (truncate x) 1) < x <= from_int (truncate x) `````` MARCHE Claude committed Mar 26, 2010 94 95 `````` axiom Real_of_truncate: `````` Andrei Paskevich committed Jun 21, 2010 96 `````` forall x:real. x - 1.0 <= from_int (truncate x) <= x + 1.0 `````` MARCHE Claude committed Mar 26, 2010 97 98 `````` axiom Truncate_monotonic: `````` Andrei Paskevich committed Jun 21, 2010 99 `````` forall x y:real. x <= y -> Int.(<=) (truncate x) (truncate y) `````` MARCHE Claude committed Mar 26, 2010 100 101 `````` axiom Truncate_monotonic_int1: `````` Andrei Paskevich committed Jun 21, 2010 102 `````` forall x:real, i:int. x <= from_int i -> Int.(<=) (truncate x) i `````` MARCHE Claude committed Mar 26, 2010 103 104 `````` axiom Truncate_monotonic_int2: `````` Andrei Paskevich committed Jun 21, 2010 105 `````` forall x:real, i:int. from_int i <= x -> Int.(<=) i (truncate x) `````` MARCHE Claude committed Mar 26, 2010 106 107 108 `````` (* roundings up and down *) `````` Andrei Paskevich committed Jun 24, 2010 109 110 `````` logic floor real : int logic ceil real : int `````` MARCHE Claude committed Mar 26, 2010 111 112 `````` axiom Floor_int : `````` Andrei Paskevich committed Jun 21, 2010 113 `````` forall i:int. floor (from_int i) = i `````` MARCHE Claude committed Mar 26, 2010 114 115 `````` axiom Ceil_int : `````` Andrei Paskevich committed Jun 21, 2010 116 `````` forall i:int. floor (from_int i) = i `````` MARCHE Claude committed Mar 26, 2010 117 118 `````` axiom Floor_down: `````` Andrei Paskevich committed Jun 21, 2010 119 `````` forall x:real. from_int (floor x) <= x < from_int (Int.(+) (floor x) 1) `````` MARCHE Claude committed Mar 26, 2010 120 121 `````` axiom Ceil_up: `````` Andrei Paskevich committed Jun 21, 2010 122 `````` forall x:real. from_int (Int.(-) (ceil x) 1) < x <= from_int (ceil x) `````` MARCHE Claude committed Mar 26, 2010 123 124 `````` axiom Floor_monotonic: `````` Andrei Paskevich committed Jun 21, 2010 125 `````` forall x y:real. x <= y -> Int.(<=) (floor x) (floor y) `````` MARCHE Claude committed Mar 26, 2010 126 127 `````` axiom Ceil_monotonic: `````` Andrei Paskevich committed Jun 21, 2010 128 `````` forall x y:real. x <= y -> Int.(<=) (ceil x) (ceil y) `````` Jean-Christophe Filliâtre committed Mar 23, 2010 129 130 131 `````` end `````` MARCHE Claude committed Mar 26, 2010 132 `````` `````` MARCHE Claude committed Mar 24, 2010 133 134 135 136 ``````theory Square use import Real `````` Andrei Paskevich committed Jun 24, 2010 137 `````` logic sqr (x : real) : real = x * x `````` MARCHE Claude committed Mar 24, 2010 138 `````` `````` Andrei Paskevich committed Jun 24, 2010 139 `````` logic sqrt real : real `````` MARCHE Claude committed Mar 24, 2010 140 141 `````` axiom Sqrt_positive: `````` Andrei Paskevich committed Jun 21, 2010 142 `````` forall x:real. x >= 0.0 -> sqrt x >= 0.0 `````` MARCHE Claude committed Mar 24, 2010 143 144 `````` axiom Sqrt_square: `````` Andrei Paskevich committed Jun 21, 2010 145 `````` forall x:real. x >= 0.0 -> sqr (sqrt x) = x `````` MARCHE Claude committed Mar 24, 2010 146 147 `````` axiom Square_sqrt: `````` Andrei Paskevich committed Jun 21, 2010 148 `````` forall x:real. x >= 0.0 -> sqrt (x*x) = x `````` Jean-Christophe Filliâtre committed Mar 23, 2010 149 150 151 `````` end `````` MARCHE Claude committed Mar 29, 2010 152 153 154 155 ``````theory SquareTest use import Square `````` Andrei Paskevich committed Jun 21, 2010 156 157 158 `````` lemma Sqrt_zero: sqrt 0.0 = 0.0 lemma Sqrt_one: sqrt 1.0 = 1.0 lemma Sqrt_four: sqrt 4.0 = 2.0 `````` MARCHE Claude committed Mar 29, 2010 159 160 161 `````` end `````` Jean-Christophe Filliâtre committed Mar 23, 2010 162 163 ``````theory ExpLog `````` MARCHE Claude committed Mar 24, 2010 164 165 `````` use import Real `````` Andrei Paskevich committed Jun 24, 2010 166 `````` logic exp real : real `````` MARCHE Claude committed Mar 24, 2010 167 `````` axiom Exp_zero : exp(0.0) = 1.0 `````` Andrei Paskevich committed Jun 21, 2010 168 `````` axiom Exp_sum : forall x y:real. exp (x+y) = exp x * exp y `````` MARCHE Claude committed Mar 24, 2010 169 `````` `````` Andrei Paskevich committed Jun 21, 2010 170 `````` logic e : real = exp 1.0 `````` MARCHE Claude committed Mar 25, 2010 171 `````` `````` Andrei Paskevich committed Jun 24, 2010 172 `````` logic log real : real `````` Andrei Paskevich committed Jun 21, 2010 173 `````` axiom Log_one : log 1.0 = 0.0 `````` MARCHE Claude committed Mar 24, 2010 174 `````` axiom Log_mul : `````` Andrei Paskevich committed Jun 21, 2010 175 `````` forall x y:real. x > 0.0 and y > 0.0 -> log (x*y) = log x + log y `````` MARCHE Claude committed Mar 24, 2010 176 `````` `````` Andrei Paskevich committed Jun 21, 2010 177 `````` axiom Log_exp: forall x:real. log (exp x) = x `````` MARCHE Claude committed Mar 24, 2010 178 `````` `````` Andrei Paskevich committed Jun 21, 2010 179 `````` axiom Exp_log: forall x:real. x > 0.0 -> exp (log x) = x `````` MARCHE Claude committed Mar 24, 2010 180 `````` `````` Andrei Paskevich committed Jun 24, 2010 181 182 `````` logic log2 (x : real) : real = log x / log 2.0 logic log10 (x : real) : real = log x / log 10.0 `````` Jean-Christophe Filliâtre committed Mar 23, 2010 183 184 185 `````` end `````` MARCHE Claude committed Mar 29, 2010 186 187 188 189 ``````theory ExpLogTest use import ExpLog `````` Andrei Paskevich committed Jun 21, 2010 190 `````` lemma Log_e : log e = 1.0 `````` MARCHE Claude committed Mar 29, 2010 191 192 193 194 `````` end `````` Jean-Christophe Filliâtre committed Mar 23, 2010 195 196 ``````theory Power `````` MARCHE Claude committed Mar 24, 2010 197 198 199 200 `````` use import Real use import Square use import ExpLog `````` Andrei Paskevich committed Jun 24, 2010 201 `````` logic pow real real : real `````` MARCHE Claude committed Mar 24, 2010 202 203 `````` axiom Pow_zero_y: `````` Andrei Paskevich committed Jun 21, 2010 204 `````` forall y:real. y <> 0.0 -> pow 0.0 y = 0.0 `````` MARCHE Claude committed Mar 24, 2010 205 206 `````` axiom Pow_x_zero: `````` Andrei Paskevich committed Jun 21, 2010 207 `````` forall x:real. x <> 0.0 -> pow x 0.0 = 1.0 `````` MARCHE Claude committed Mar 24, 2010 208 209 `````` axiom Pow_x_one: `````` Andrei Paskevich committed Jun 21, 2010 210 `````` forall x:real. pow x 1.0 = x `````` MARCHE Claude committed Mar 24, 2010 211 212 `````` axiom Pow_one_y: `````` Andrei Paskevich committed Jun 21, 2010 213 `````` forall y:real. pow 1.0 y = 1.0 `````` MARCHE Claude committed Mar 24, 2010 214 215 `````` axiom Pow_x_two: `````` Andrei Paskevich committed Jun 21, 2010 216 `````` forall x:real. pow x 2.0 = sqr x `````` MARCHE Claude committed Mar 24, 2010 217 218 `````` axiom Pow_half: `````` Andrei Paskevich committed Jun 21, 2010 219 `````` forall x:real. x >= 0.0 -> pow x 0.5 = sqrt x `````` MARCHE Claude committed Mar 24, 2010 220 221 `````` axiom Pow_exp_log: `````` Andrei Paskevich committed Jun 21, 2010 222 `````` forall x y:real. x > 0.0 -> pow x y = exp (y * log x) `````` MARCHE Claude committed Mar 24, 2010 223 `````` `````` Jean-Christophe Filliâtre committed Mar 23, 2010 224 225 ``````end `````` MARCHE Claude committed Mar 29, 2010 226 227 228 229 ``````theory PowerTest use import Power `````` Andrei Paskevich committed Jun 21, 2010 230 `````` lemma Pow_2_2 : pow 2.0 2.0 = 4.0 `````` MARCHE Claude committed Mar 29, 2010 231 232 233 234 235 `````` end `````` MARCHE Claude committed Mar 25, 2010 236 237 238 ``````(** Trigonometric functions [http://en.wikipedia.org/wiki/Trigonometric_function] *) `````` MARCHE Claude committed Mar 29, 2010 239 ``````theory Trigonometry `````` MARCHE Claude committed Mar 25, 2010 240 241 242 243 244 `````` use import Real use import Square use import Abs `````` Andrei Paskevich committed Jun 24, 2010 245 246 `````` logic cos real : real logic sin real : real `````` MARCHE Claude committed Mar 25, 2010 247 248 `````` axiom Pythagorean_identity: `````` Andrei Paskevich committed Jun 21, 2010 249 `````` forall x:real. sqr (cos x) + sqr (sin x) = 1.0 `````` MARCHE Claude committed Mar 25, 2010 250 `````` `````` Andrei Paskevich committed Jun 21, 2010 251 252 `````` lemma Cos_le_one: forall x:real. abs (cos x) <= 1.0 lemma Sin_le_one: forall x:real. abs (sin x) <= 1.0 `````` MARCHE Claude committed Mar 25, 2010 253 `````` `````` Andrei Paskevich committed Jun 21, 2010 254 255 `````` axiom Cos_0: cos 0.0 = 1.0 axiom Sin_0: sin 0.0 = 0.0 `````` MARCHE Claude committed Mar 25, 2010 256 257 258 `````` logic pi : real `````` MARCHE Claude committed Apr 08, 2010 259 260 261 262 263 `````` axiom Pi_interval: 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196 < pi < 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038197 `````` Andrei Paskevich committed Jun 21, 2010 264 265 `````` axiom Cos_pi: cos pi = -1.0 axiom Sin_pi: sin pi = 0.0 `````` MARCHE Claude committed Mar 25, 2010 266 `````` `````` Andrei Paskevich committed Jun 21, 2010 267 268 `````` axiom Cos_pi2: cos (0.5 * pi) = 0.0 axiom Sin_pi2: sin (0.5 * pi) = 1.0 `````` Jean-Christophe Filliâtre committed Mar 23, 2010 269 `````` `````` Andrei Paskevich committed Jun 21, 2010 270 271 `````` axiom Cos_plus_pi: forall x:real. cos (x + pi) = - cos x axiom Sin_plus_pi: forall x:real. sin (x + pi) = - sin x `````` MARCHE Claude committed Mar 25, 2010 272 `````` `````` Andrei Paskevich committed Jun 21, 2010 273 274 `````` axiom Cos_plus_pi2: forall x:real. cos (x + 0.5*pi) = - sin x axiom Sin_plus_pi2: forall x:real. sin (x + 0.5*pi) = cos x `````` MARCHE Claude committed Mar 25, 2010 275 276 `````` axiom Cos_neg: `````` Andrei Paskevich committed Jun 21, 2010 277 `````` forall x:real. cos (-x) = cos x `````` MARCHE Claude committed Mar 25, 2010 278 `````` axiom Sin_neg: `````` Andrei Paskevich committed Jun 21, 2010 279 `````` forall x:real. sin (-x) = - sin x `````` MARCHE Claude committed Mar 25, 2010 280 281 `````` axiom Cos_sum: `````` Andrei Paskevich committed Jun 21, 2010 282 `````` forall x y:real. cos (x+y) = cos x * cos y - sin x * sin y `````` MARCHE Claude committed Mar 25, 2010 283 `````` axiom Sin_sum: `````` Andrei Paskevich committed Jun 21, 2010 284 `````` forall x y:real. sin (x+y) = sin x * cos y + cos x * sin y `````` MARCHE Claude committed Mar 25, 2010 285 `````` `````` Andrei Paskevich committed Jun 24, 2010 286 287 `````` logic tan (x : real) : real = sin x / cos x logic atan real : real `````` MARCHE Claude committed Mar 25, 2010 288 `````` axiom Tan_atan: `````` Andrei Paskevich committed Jun 21, 2010 289 `````` forall x:real. tan (atan x) = x `````` Jean-Christophe Filliâtre committed Mar 23, 2010 290 291 292 `````` end `````` MARCHE Claude committed Mar 29, 2010 293 294 295 296 297 298 ``````theory TrigonometryTest use import Real use import Trigonometry use import Square `````` Andrei Paskevich committed Jun 21, 2010 299 `````` lemma Cos_2_pi : cos (2.0 * pi) = 1.0 `````` Jean-Christophe Filliâtre committed Jul 08, 2010 300 `````` lemma Sin_2_pi : sin (2.0 * pi) = 0. `````` Andrei Paskevich committed Jun 21, 2010 301 302 `````` lemma Tan_pi_3 : tan (pi / 2.0) = sqrt 3.0 lemma Atan_1 : atan 1.0 = pi / 4.0 `````` MARCHE Claude committed Mar 29, 2010 303 304 305 `````` end `````` MARCHE Claude committed Mar 25, 2010 306 307 308 ``````(** hyperbolic functions [http://en.wikipedia.org/wiki/Hyperbolic_function] *) `````` Jean-Christophe Filliâtre committed Mar 23, 2010 309 310 ``````theory Hyperbolic `````` MARCHE Claude committed Mar 25, 2010 311 312 313 314 `````` use import Real use import Square use import ExpLog `````` Andrei Paskevich committed Jun 24, 2010 315 316 317 `````` logic sinh (x : real) : real = 0.5 * (exp x - exp (-x)) logic cosh (x : real) : real = 0.5 * (exp x + exp (-x)) logic tanh (x : real) : real = sinh x / cosh x `````` MARCHE Claude committed Mar 25, 2010 318 `````` `````` Andrei Paskevich committed Jun 24, 2010 319 320 `````` logic arsinh (x : real) : real = log (x + sqrt (sqr x + 1.0)) logic arcosh (x : real) : real `````` MARCHE Claude committed Mar 25, 2010 321 `````` axiom Arcosh_def: `````` Andrei Paskevich committed Jun 21, 2010 322 `````` forall x:real. x >= 1.0 -> arcosh x = log (x + sqrt (sqr x - 1.0)) `````` Andrei Paskevich committed Jun 24, 2010 323 `````` logic artanh (x : real) : real `````` MARCHE Claude committed Mar 25, 2010 324 `````` axiom Artanh_def: `````` Andrei Paskevich committed Jun 21, 2010 325 `````` forall x:real. -1.0 < x < 1.0 -> artanh x = 0.5 * log ((1.0+x)/(1.0-x)) `````` Jean-Christophe Filliâtre committed Mar 23, 2010 326 327 328 `````` end `````` MARCHE Claude committed Mar 25, 2010 329 330 331 ``````(** polar coordinates: atan2, hypot [http://en.wikipedia.org/wiki/Atan2] *) `````` Jean-Christophe Filliâtre committed Mar 23, 2010 332 333 ``````theory Polar `````` MARCHE Claude committed Mar 25, 2010 334 335 `````` use import Real use import Square `````` MARCHE Claude committed Mar 29, 2010 336 `````` use import Trigonometry `````` MARCHE Claude committed Mar 25, 2010 337 `````` `````` Andrei Paskevich committed Jun 24, 2010 338 339 `````` logic hypot (x y : real) : real = sqrt (sqr x + sqr y) logic atan2 real real : real `````` Jean-Christophe Filliâtre committed Mar 23, 2010 340 `````` `````` MARCHE Claude committed Mar 25, 2010 341 `````` axiom X_from_polar: `````` Andrei Paskevich committed Jun 21, 2010 342 `````` forall x y:real. x = hypot x y * cos (atan2 y x) `````` MARCHE Claude committed Mar 25, 2010 343 344 `````` axiom Y_from_polar: `````` Andrei Paskevich committed Jun 21, 2010 345 `````` forall x y:real. y = hypot x y * sin (atan2 y x) `````` Jean-Christophe Filliâtre committed Mar 23, 2010 346 347 ``````end ``````