annotate src/HyperReal.agda @ 0:8c492c69514c

HyperReal
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 18 Mar 2021 16:55:49 +0900
parents
children b50a277631e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module HyperReal where
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Data.Nat
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Data.Nat.Properties
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Empty
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Relation.Nullary using (¬_; Dec; yes; no)
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Level renaming ( suc to succ ; zero to Zero )
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 open import Relation.Binary.PropositionalEquality hiding ( [_] )
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Relation.Binary.Definitions
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 hnzero : (ℕ → ℕ) → Set
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 hnzero f = (x : ℕ) → ¬ ( x ≡ zero )
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 data HyperReal : Set where
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 hnat : (ℕ → ℕ) → HyperReal
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 hadd : HyperReal → (x : ℕ → ℕ ) → HyperReal
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 hsub : HyperReal → (x : ℕ → ℕ ) → HyperReal
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 hdiv : HyperReal → (x : ℕ → ℕ ) → hnzero x → HyperReal
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 data Rational : Set where
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 rat : ℕ → ℕ → (z : ℕ) → ¬ (z ≡ zero) → Rational -- (x - y ) / z
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 prat : Rational → ℕ
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 prat (rat x _ _ _ ) = x
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 mrat : Rational → ℕ
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 mrat (rat _ y _ _ ) = y
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 drat : Rational → ℕ
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 drat (rat _ _ z _ ) = z
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 zrat : (r : Rational ) → ¬ (drat r ≡ zero)
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 zrat (rat _ _ z ne ) = ne
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 HyRa←R : HyperReal → (ℕ → Rational)
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 HyRa←R (hnat x) i = rat (x i) 0 1 (λ ())
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 HyRa←R (hadd x y) i with HyRa←R x i
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 ... | rat w v z ne = rat (w + z * (y i)) v z ne
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 HyRa←R (hsub x y) i with HyRa←R x i
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 ... | rat w v z ne = rat w (v + z * (y i)) z ne
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 HyRa←R (hdiv x y nz) i with HyRa←R x i
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 ... | rat w v z ne = rat w v (z * (y i)) {!!}
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 HyR←Ra : (ℕ → Rational) → HyperReal
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 HyR←Ra r = hdiv (hsub (hnat (λ i → prat (r i))) (λ i → mrat (r i))) (λ i → drat (r i)) {!!}