haskell-te: 5f3975c88a880608c6d395cbac2ad6d94bcecaaa
1: ; Lists with Nil, Cons, append, reverse, length, map, foldl and foldr; various
2: ; combinations of these have been used to test HipSpec
3: (declare-datatypes (a)
4: ((List (Nil) (Cons (head a) (tail (List a))))))
5: (declare-datatypes () ((Nat (Z) (S (p Nat)))))
6:
7: ; Functions equivalent to the constructors
8: (define-fun
9: (par (a)
10: (constructor-Nil () (List a)
11: (as Nil (List a)))))
12:
13: (define-fun
14: (par (a)
15: (constructor-Cons ((local-head a) (local-tail (List a))) (List a)
16: (as (Cons local-head local-tail) (List a)))))
17:
18: (define-fun constructor-Z () Nat
19: (as Z Nat))
20:
21: (define-fun constructor-S ((local-p Nat)) Nat
22: (as (S local-p) Nat))
23:
24: ; Functions equivalent to the destructors
25: (define-fun
26: (par (a)
27: (destructor-head ((local-x (List a))) a
28: (match local-x
29: (case (Cons local-head local-tail) local-head)))))
30:
31: (define-fun
32: (par (a)
33: (destructor-tail ((local-x (List a))) (List a)
34: (match local-x
35: (case (Cons local-head local-tail) local-tail)))))
36:
37: (define-fun destructor-p ((local-x Nat)) Nat
38: (match local-x
39: (case (S local-p) local-p)))
40:
41: ; Other functions
42: (define-fun-rec
43: (par (a)
44: (append
45: ((x (List a)) (y (List a))) (List a)
46: (match x
47: (case Nil y)
48: (case (Cons z xs) (Cons z (append xs y)))))))
49: (define-fun-rec
50: (par (a)
51: (reverse
52: ((x (List a))) (List a)
53: (match x
54: (case Nil (as Nil (List a)))
55: (case (Cons z xs) (append (reverse xs) (Cons z (as Nil (List a)))))))))
56: (define-fun-rec
57: (par (a)
58: (length
59: ((x (List a))) (Nat)
60: (match x
61: (case Nil Z)
62: (case (Cons z xs) (S (length xs)))))))
63: (define-fun-rec
64: (par (a b)
65: (map
66: ((x (=> a b)) (y (List a))) (List b)
67: (match y
68: (case Nil (as Nil (List b)))
69: (case (Cons z xs) (as (Cons (@ x z) (map x xs)) (List b)))))))
70: (define-fun-rec
71: (par (a b)
72: (foldl
73: ((f (=> b (=> a b))) (x b) (y (List a))) b
74: (match y
75: (case Nil x)
76: (case (Cons z xs) (foldl f (@ (@ f x) z) xs))))))
77: (define-fun-rec
78: (par (a b)
79: (foldr
80: ((f (=> a (=> b b))) (y (List a)) (x b)) b
81: (match y
82: (case Nil x)
83: (case (Cons h t) (@ (@ f h) (foldr f t x)))))))
84: (check-sat)
Generated by git2html.