2608
|
1 |
(* Title: HOL/NatDef.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Tobias Nipkow, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1991 University of Cambridge
|
|
5 |
|
|
6 |
Definition of types ind and nat.
|
|
7 |
|
|
8 |
Type nat is defined as a set Nat over type ind.
|
|
9 |
*)
|
|
10 |
|
|
11 |
NatDef = WF +
|
|
12 |
|
|
13 |
(** type ind **)
|
|
14 |
|
3947
|
15 |
global
|
|
16 |
|
2608
|
17 |
types
|
|
18 |
ind
|
|
19 |
|
|
20 |
arities
|
|
21 |
ind :: term
|
|
22 |
|
|
23 |
consts
|
|
24 |
Zero_Rep :: ind
|
|
25 |
Suc_Rep :: ind => ind
|
|
26 |
|
|
27 |
rules
|
|
28 |
(*the axiom of infinity in 2 parts*)
|
|
29 |
inj_Suc_Rep "inj(Suc_Rep)"
|
|
30 |
Suc_Rep_not_Zero_Rep "Suc_Rep(x) ~= Zero_Rep"
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
(** type nat **)
|
|
35 |
|
|
36 |
(* type definition *)
|
|
37 |
|
|
38 |
typedef (Nat)
|
|
39 |
nat = "lfp(%X. {Zero_Rep} Un (Suc_Rep``X))" (lfp_def)
|
|
40 |
|
|
41 |
instance
|
|
42 |
nat :: ord
|
|
43 |
|
|
44 |
|
|
45 |
(* abstract constants and syntax *)
|
|
46 |
|
|
47 |
consts
|
|
48 |
"0" :: nat ("0")
|
|
49 |
Suc :: nat => nat
|
|
50 |
nat_case :: ['a, nat => 'a, nat] => 'a
|
|
51 |
pred_nat :: "(nat * nat) set"
|
|
52 |
nat_rec :: ['a, [nat, 'a] => 'a, nat] => 'a
|
|
53 |
|
|
54 |
syntax
|
|
55 |
"1" :: nat ("1")
|
|
56 |
"2" :: nat ("2")
|
|
57 |
|
|
58 |
translations
|
|
59 |
"1" == "Suc 0"
|
|
60 |
"2" == "Suc 1"
|
3842
|
61 |
"case p of 0 => a | Suc y => b" == "nat_case a (%y. b) p"
|
2608
|
62 |
|
|
63 |
|
3947
|
64 |
local
|
|
65 |
|
2608
|
66 |
defs
|
|
67 |
Zero_def "0 == Abs_Nat(Zero_Rep)"
|
|
68 |
Suc_def "Suc == (%n. Abs_Nat(Suc_Rep(Rep_Nat(n))))"
|
|
69 |
|
|
70 |
(*nat operations and recursion*)
|
|
71 |
nat_case_def "nat_case a f n == @z. (n=0 --> z=a)
|
|
72 |
& (!x. n=Suc x --> z=f(x))"
|
3236
|
73 |
pred_nat_def "pred_nat == {(m,n). n = Suc m}"
|
2608
|
74 |
|
|
75 |
less_def "m<n == (m,n):trancl(pred_nat)"
|
|
76 |
|
|
77 |
le_def "m<=(n::nat) == ~(n<m)"
|
|
78 |
|
|
79 |
nat_rec_def "nat_rec c d ==
|
|
80 |
wfrec pred_nat (%f. nat_case c (%m. d m (f m)))"
|
|
81 |
end
|