11 defaultsort type |
11 defaultsort type |
12 |
12 |
13 types 'a fstream = "('a lift) stream" |
13 types 'a fstream = "('a lift) stream" |
14 |
14 |
15 definition |
15 definition |
16 fsingleton :: "'a => 'a fstream" ("<_>" [1000] 999) |
16 fsingleton :: "'a => 'a fstream" ("<_>" [1000] 999) where |
17 fsingleton_def2: "fsingleton = (%a. Def a && UU)" |
17 fsingleton_def2: "fsingleton = (%a. Def a && UU)" |
18 |
18 |
19 fsfilter :: "'a set \<Rightarrow> 'a fstream \<rightarrow> 'a fstream" |
19 definition |
|
20 fsfilter :: "'a set \<Rightarrow> 'a fstream \<rightarrow> 'a fstream" where |
20 "fsfilter A = sfilter\<cdot>(flift2 (\<lambda>x. x\<in>A))" |
21 "fsfilter A = sfilter\<cdot>(flift2 (\<lambda>x. x\<in>A))" |
21 |
22 |
22 fsmap :: "('a => 'b) => 'a fstream -> 'b fstream" |
23 definition |
|
24 fsmap :: "('a => 'b) => 'a fstream -> 'b fstream" where |
23 "fsmap f = smap$(flift2 f)" |
25 "fsmap f = smap$(flift2 f)" |
24 |
26 |
25 jth :: "nat => 'a fstream => 'a" |
27 definition |
|
28 jth :: "nat => 'a fstream => 'a" where |
26 "jth = (%n s. if Fin n < #s then THE a. i_th n s = Def a else arbitrary)" |
29 "jth = (%n s. if Fin n < #s then THE a. i_th n s = Def a else arbitrary)" |
27 |
30 |
28 first :: "'a fstream => 'a" |
31 definition |
|
32 first :: "'a fstream => 'a" where |
29 "first = (%s. jth 0 s)" |
33 "first = (%s. jth 0 s)" |
30 |
34 |
31 last :: "'a fstream => 'a" |
35 definition |
|
36 last :: "'a fstream => 'a" where |
32 "last = (%s. case #s of Fin n => (if n~=0 then jth (THE k. Suc k = n) s else arbitrary) |
37 "last = (%s. case #s of Fin n => (if n~=0 then jth (THE k. Suc k = n) s else arbitrary) |
33 | Infty => arbitrary)" |
38 | Infty => arbitrary)" |
34 |
39 |
35 |
40 |
36 abbreviation |
41 abbreviation |
37 emptystream :: "'a fstream" ("<>") |
42 emptystream :: "'a fstream" ("<>") where |
38 "<> == \<bottom>" |
43 "<> == \<bottom>" |
39 fsfilter' :: "'a set \<Rightarrow> 'a fstream \<Rightarrow> 'a fstream" ("(_'(C')_)" [64,63] 63) |
44 |
|
45 abbreviation |
|
46 fsfilter' :: "'a set \<Rightarrow> 'a fstream \<Rightarrow> 'a fstream" ("(_'(C')_)" [64,63] 63) where |
40 "A(C)s == fsfilter A\<cdot>s" |
47 "A(C)s == fsfilter A\<cdot>s" |
41 |
48 |
42 notation (xsymbols) |
49 notation (xsymbols) |
43 fsfilter' ("(_\<copyright>_)" [64,63] 63) |
50 fsfilter' ("(_\<copyright>_)" [64,63] 63) |
44 |
51 |