equal
deleted
inserted
replaced
1 (* Title: HOL/Word/Type_Length.thy |
1 (* Title: HOL/Word/Type_Length.thy |
2 Author: John Matthews, Galois Connections, Inc., copyright 2006 |
2 Author: John Matthews, Galois Connections, Inc., copyright 2006 |
3 *) |
3 *) |
4 |
4 |
5 section {* Assigning lengths to types by typeclasses *} |
5 section \<open>Assigning lengths to types by typeclasses\<close> |
6 |
6 |
7 theory Type_Length |
7 theory Type_Length |
8 imports "~~/src/HOL/Library/Numeral_Type" |
8 imports "~~/src/HOL/Library/Numeral_Type" |
9 begin |
9 begin |
10 |
10 |
11 text {* |
11 text \<open> |
12 The aim of this is to allow any type as index type, but to provide a |
12 The aim of this is to allow any type as index type, but to provide a |
13 default instantiation for numeral types. This independence requires |
13 default instantiation for numeral types. This independence requires |
14 some duplication with the definitions in @{text "Numeral_Type"}. |
14 some duplication with the definitions in \<open>Numeral_Type\<close>. |
15 *} |
15 \<close> |
16 |
16 |
17 class len0 = |
17 class len0 = |
18 fixes len_of :: "'a itself \<Rightarrow> nat" |
18 fixes len_of :: "'a itself \<Rightarrow> nat" |
19 |
19 |
20 text {* |
20 text \<open> |
21 Some theorems are only true on words with length greater 0. |
21 Some theorems are only true on words with length greater 0. |
22 *} |
22 \<close> |
23 |
23 |
24 class len = len0 + |
24 class len = len0 + |
25 assumes len_gt_0 [iff]: "0 < len_of TYPE ('a)" |
25 assumes len_gt_0 [iff]: "0 < len_of TYPE ('a)" |
26 |
26 |
27 instantiation num0 and num1 :: len0 |
27 instantiation num0 and num1 :: len0 |