~ubuntu-branches/ubuntu/natty/prover9-manual/natty

« back to all changes in this revision

Viewing changes to list.in

  • Committer: Bazaar Package Importer
  • Author(s): Peter Collingbourne
  • Date: 2009-03-15 00:53:52 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090315005352-o9rzionfe6y7vnys
Tags: 0.0.200902a-1
* New upstream release.
* debian/examples: updated
* debian/control: new Standards-Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
% This Prover9 input doesn't do anything meaningful.  It simply contains
 
2
% some list-processing functions and relations, and it shows how they
 
3
% can be tested.
 
4
 
 
5
set(production).
 
6
 
 
7
formulas(demodulators).
 
8
 
 
9
% Relations and Properties
 
10
 
 
11
-member(x,[]).
 
12
member(x,[y:z]) <-> if(x == y, $T, member(x,z)).
 
13
 
 
14
subset([], x).
 
15
subset([x:y], z) <-> member(x,z) & subset(y,z).
 
16
 
 
17
is_set([]).
 
18
is_set([x:y]) <-> -member(x,y) & is_set(y).
 
19
 
 
20
% Functions
 
21
 
 
22
set([]) = [].
 
23
set([x:y]) = if(member(x,y), set(y), [x:set(y)]).
 
24
 
 
25
append([], x) = x.
 
26
append([x:y], z) = [x:append(y,z)].
 
27
 
 
28
intersect([], x) = [].
 
29
intersect([x:y],z) = if(member(x,z),[x:intersect(y,z)],intersect(y,z)).
 
30
 
 
31
union([], x) = x.
 
32
union([x:y], z) = if(member(x,z),union(y,z),[x:union(y,z)]).
 
33
 
 
34
diff([], x) = [].
 
35
diff([x:y], z) = if(member(x,z),diff(y,z),[x:diff(y,z)]).
 
36
 
 
37
reverse(x) = rev_app(x,[]).
 
38
rev_app([], x) = x.
 
39
rev_app([x:y],z) = rev_app(y,[x:z]).
 
40
 
 
41
quick_sort([]) = [].               % naive quicksort
 
42
quick_sort([x:y]) = append(quick_sort(le_list(x,y)),
 
43
                           [x:quick_sort(gt_list(x,y))]).
 
44
 
 
45
le_list(z,[]) = [].
 
46
le_list(z,[x:y]) = if(x @<= z,[x:le_list(z,y)], le_list(z,y)).
 
47
 
 
48
gt_list(z,[]) = [].
 
49
gt_list(z,[x:y]) = if(x @> z, [x:gt_list(z,y)], gt_list(z,y)).
 
50
 
 
51
end_of_list.
 
52
 
 
53
formulas(assumptions).
 
54
 
 
55
% We're simply going to test some of the function and relations written
 
56
% above.  The assumptions here will be rewritten by the rules above,
 
57
% and the results will appear in the output just after the line
 
58
% "Clauses after input processing:".
 
59
 
 
60
% Test functions, we can simply use a dummy predicate.
 
61
 
 
62
Test1(2+3).
 
63
Test2(reverse(union([a,b,c],[d,b,f]))).
 
64
Test3(quick_sort([r,e,g,d,f,w,x,c,e,d,r,y,i,b,j,h,v,x,e,d,d,e,t])).
 
65
Test4(diff([a,b,c,d,e],[c,d,e,f,g])).
 
66
Test5(set([a,b,a,b,b,c])).
 
67
 
 
68
% Testing relations and properties is awkward, because if a literal
 
69
% rewrites to $T (true), the clause becomes a tautology and disappears;
 
70
% if a literal rewrites to $F (false), the literal disappears.  We can
 
71
% use implications as follows.
 
72
 
 
73
 member(b,[a,b,c]) -> Member_test_true.
 
74
-member(b,[a,b,c]) -> Member_test_false.
 
75
 
 
76
 is_set([a,b,c,a,d]) -> Set_test_true.
 
77
-is_set([a,b,c,a,d]) -> Set_test_false.
 
78
 
 
79
end_of_list.
 
80