-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathchar.agda
More file actions
67 lines (52 loc) Β· 1.66 KB
/
char.agda
File metadata and controls
67 lines (52 loc) Β· 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
module char where
open import bool
open import nat
open import eq
open import product
open import product-thms
----------------------------------------------------------------------
-- datatypes
----------------------------------------------------------------------
postulate
char : Set
{-# BUILTIN CHAR char #-}
----------------------------------------------------------------------
-- primitive operations
----------------------------------------------------------------------
private
primitive
primCharToNat : char β β
primCharEquality : char β char β πΉ
toNat : char β β
toNat = primCharToNat
infix 4 _=char_
_=char_ : char β char β πΉ
_=char_ = primCharEquality
postulate
β‘char-to-= : (c1 c2 : char) β c1 β‘ c2 β _=char_ c1 c2 β‘ tt
=char-to-β‘ : (c1 c2 : char) β _=char_ c1 c2 β‘ tt β c1 β‘ c2
=char-sym : (c1 c2 : char) β (c1 =char c2) β‘ (c2 =char c1)
=char-sym c1 c2 with keep (c1 =char c2)
=char-sym c1 c2 | tt , p rewrite =char-to-β‘ c1 c2 p = refl
=char-sym c1 c2 | ff , p with keep (c2 =char c1)
=char-sym c1 c2 | ff , p | tt , p' rewrite =char-to-β‘ c2 c1 p' = refl
=char-sym c1 c2 | ff , p | ff , p' rewrite p | p' = refl
postulate
_<char_ : char β char β πΉ
{-# COMPILE GHC _<char_ = (<) #-}
----------------------------------------------------------------------
-- defined operations
----------------------------------------------------------------------
-- is a decimal digit
is-digit : char β πΉ
is-digit '0' = tt
is-digit '1' = tt
is-digit '2' = tt
is-digit '3' = tt
is-digit '4' = tt
is-digit '5' = tt
is-digit '6' = tt
is-digit '7' = tt
is-digit '8' = tt
is-digit '9' = tt
is-digit _ = ff