src/HOL/Hyperreal/HyperArith.thy
author huffman
Wed, 27 Sep 2006 07:09:19 +0200
changeset 20730 da903f59e9ba
parent 20539 a7b2f90f698d
child 21404 eb85850d3eb7
permissions -rw-r--r--
hypreal_of_nat abbreviates of_nat
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
     1
(*  Title:      HOL/HyperArith.thy
14369
c50188fe6366 tidying up arithmetic for the hyperreals
paulson
parents: 14352
diff changeset
     2
    ID:         $Id$
c50188fe6366 tidying up arithmetic for the hyperreals
paulson
parents: 14352
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
c50188fe6366 tidying up arithmetic for the hyperreals
paulson
parents: 14352
diff changeset
     4
    Copyright   1999  University of Cambridge
c50188fe6366 tidying up arithmetic for the hyperreals
paulson
parents: 14352
diff changeset
     5
*)
c50188fe6366 tidying up arithmetic for the hyperreals
paulson
parents: 14352
diff changeset
     6
c50188fe6366 tidying up arithmetic for the hyperreals
paulson
parents: 14352
diff changeset
     7
header{*Binary arithmetic and Simplification for the Hyperreals*}
c50188fe6366 tidying up arithmetic for the hyperreals
paulson
parents: 14352
diff changeset
     8
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15013
diff changeset
     9
theory HyperArith
15140
322485b816ac import -> imports
nipkow
parents: 15131
diff changeset
    10
imports HyperDef
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15140
diff changeset
    11
uses ("hypreal_arith.ML")
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15013
diff changeset
    12
begin
14387
e96d5c42c4b0 Polymorphic treatment of binary arithmetic using axclasses
paulson
parents: 14378
diff changeset
    13
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    14
subsection{*Absolute Value Function for the Hyperreals*}
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    15
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14387
diff changeset
    16
lemma hrabs_add_less:
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14387
diff changeset
    17
     "[| abs x < r; abs y < s |] ==> abs(x+y) < r + (s::hypreal)"
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14387
diff changeset
    18
by (simp add: abs_if split: split_if_asm)
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    19
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    20
lemma hrabs_less_gt_zero: "abs x < r ==> (0::hypreal) < r"
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    21
by (blast intro!: order_le_less_trans abs_ge_zero)
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    22
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    23
lemma hrabs_disj: "abs x = (x::hypreal) | abs x = -x"
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14387
diff changeset
    24
by (simp add: abs_if)
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    25
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    26
lemma hrabs_add_lemma_disj: "(y::hypreal) + - x + (y + - z) = abs (x + - z) ==> y = z | x = y"
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14387
diff changeset
    27
by (simp add: abs_if split add: split_if_asm)
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    28
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    29
lemma hypreal_of_real_hrabs:
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    30
    "abs (hypreal_of_real r) = hypreal_of_real (abs r)"
17318
bc1c75855f3d starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents: 17298
diff changeset
    31
by (rule star_of_abs [symmetric])
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    32
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    33
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    34
subsection{*Embedding the Naturals into the Hyperreals*}
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    35
20730
da903f59e9ba hypreal_of_nat abbreviates of_nat
huffman
parents: 20539
diff changeset
    36
abbreviation
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    37
  hypreal_of_nat   :: "nat => hypreal"
20730
da903f59e9ba hypreal_of_nat abbreviates of_nat
huffman
parents: 20539
diff changeset
    38
  "hypreal_of_nat == of_nat"
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    39
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    40
lemma SNat_eq: "Nats = {n. \<exists>N. n = hypreal_of_nat N}"
20730
da903f59e9ba hypreal_of_nat abbreviates of_nat
huffman
parents: 20539
diff changeset
    41
by (simp add: Nats_def image_def)
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    42
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    43
(*------------------------------------------------------------*)
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    44
(* naturals embedded in hyperreals                            *)
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    45
(* is a hyperreal c.f. NS extension                           *)
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    46
(*------------------------------------------------------------*)
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    47
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    48
lemma hypreal_of_nat_eq:
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    49
     "hypreal_of_nat (n::nat) = hypreal_of_real (real n)"
20730
da903f59e9ba hypreal_of_nat abbreviates of_nat
huffman
parents: 20539
diff changeset
    50
by (simp add: real_of_nat_def)
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    51
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    52
lemma hypreal_of_nat:
17318
bc1c75855f3d starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents: 17298
diff changeset
    53
     "hypreal_of_nat m = star_n (%n. real m)"
bc1c75855f3d starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents: 17298
diff changeset
    54
apply (fold star_of_def)
20730
da903f59e9ba hypreal_of_nat abbreviates of_nat
huffman
parents: 20539
diff changeset
    55
apply (simp add: real_of_nat_def)
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    56
done
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    57
14309
f508492af9b4 moving HyperArith0.ML to other theories
paulson
parents: 10751
diff changeset
    58
(*
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
    59
FIXME: we should declare this, as for type int, but many proofs would break.
14309
f508492af9b4 moving HyperArith0.ML to other theories
paulson
parents: 10751
diff changeset
    60
It replaces x+-y by x-y.
f508492af9b4 moving HyperArith0.ML to other theories
paulson
parents: 10751
diff changeset
    61
Addsimps [symmetric hypreal_diff_def]
f508492af9b4 moving HyperArith0.ML to other theories
paulson
parents: 10751
diff changeset
    62
*)
f508492af9b4 moving HyperArith0.ML to other theories
paulson
parents: 10751
diff changeset
    63
20254
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
    64
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
    65
use "hypreal_arith.ML"
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
    66
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
    67
setup hypreal_arith_setup
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
    68
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    69
end