equal
deleted
inserted
replaced
|
1 (* Title: HOL/Tools/DSeq.ML |
|
2 ID: $Id$ |
|
3 Author: Stefan Berghofer, TU Muenchen |
|
4 |
|
5 Sequences with recursion depth limit. |
|
6 *) |
|
7 |
|
8 structure DSeq = |
|
9 struct |
|
10 |
|
11 fun maps f s 0 = Seq.empty |
|
12 | maps f s i = Seq.maps (fn a => f a i) (s (i - 1)); |
|
13 |
|
14 fun map f s i = Seq.map f (s i); |
|
15 |
|
16 fun append s1 s2 i = Seq.append (s1 i) (s2 i); |
|
17 |
|
18 fun interleave s1 s2 i = Seq.interleave (s1 i, s2 i); |
|
19 |
|
20 fun single x i = Seq.single x; |
|
21 |
|
22 fun empty i = Seq.empty; |
|
23 |
|
24 fun guard b = if b then single () else empty; |
|
25 |
|
26 fun of_list xs i = Seq.of_list xs; |
|
27 |
|
28 fun list_of s = Seq.list_of (s ~1); |
|
29 |
|
30 fun pull s = Seq.pull (s ~1); |
|
31 |
|
32 fun hd s = Seq.hd (s ~1); |
|
33 |
|
34 end; |
|
35 |
|
36 |
|
37 (* combinators for code generated from inductive predicates *) |
|
38 |
|
39 infix 5 :->; |
|
40 infix 3 ++; |
|
41 |
|
42 fun s :-> f = DSeq.maps f s; |
|
43 |
|
44 fun f ++ g = DSeq.append f g; |
|
45 |
|
46 val ?? = DSeq.guard; |
|
47 |
|
48 fun ??? f g = f o g; |
|
49 |
|
50 fun ?! s = is_some (DSeq.pull s); |
|
51 |
|
52 fun equal__1 x = DSeq.single x; |
|
53 |
|
54 val equal__2 = equal__1; |
|
55 |
|
56 fun equal__1_2 (x, y) = ?? (x = y); |