| 1 | |
|---|
| 2 | :- protocol(setp). |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | :- info([ |
|---|
| 6 | version is 1.0, |
|---|
| 7 | authors is 'Paulo Moura', |
|---|
| 8 | date is 2000/7/24, |
|---|
| 9 | comment is 'Set protocol.']). |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | :- public(delete/3). |
|---|
| 13 | |
|---|
| 14 | :- mode(delete(+set, @term, ?set), one). |
|---|
| 15 | |
|---|
| 16 | :- info(delete/3, |
|---|
| 17 | [comment is 'Deletes an element from a set returning the set of remaining elements.', |
|---|
| 18 | argnames is ['Set', 'Element', 'Remaining']]). |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | :- public(disjoint/2). |
|---|
| 22 | |
|---|
| 23 | :- mode(disjoint(+set, +set), zero_or_one). |
|---|
| 24 | |
|---|
| 25 | :- info(disjoint/2, [ |
|---|
| 26 | comment is 'True if the two sets have no element in common.', |
|---|
| 27 | argnames is ['Set1', 'Set2']]). |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | :- public(equal/2). |
|---|
| 31 | |
|---|
| 32 | :- mode(equal(+set, +set), zero_or_one). |
|---|
| 33 | |
|---|
| 34 | :- info(equal/2, [ |
|---|
| 35 | comment is 'True if the two sets are equal.', |
|---|
| 36 | argnames is ['Set1', 'Set2']]). |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | :- public(empty/1). |
|---|
| 40 | |
|---|
| 41 | :- mode(empty(+set), zero_or_one). |
|---|
| 42 | |
|---|
| 43 | :- info(empty/1, [ |
|---|
| 44 | comment is 'True if the set is empty.', |
|---|
| 45 | argnames is ['Set']]). |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | :- public(insert/3). |
|---|
| 49 | |
|---|
| 50 | :- mode(insert(+set, +term, ?set), one). |
|---|
| 51 | |
|---|
| 52 | :- info(insert/3, [ |
|---|
| 53 | comment is 'Inserts an element in a set, returning the resulting set.', |
|---|
| 54 | argnames is ['In', 'Element', 'Out']]). |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | :- public(insert_all/3). |
|---|
| 58 | |
|---|
| 59 | :- mode(insert_all(+list, +set, ?set), one). |
|---|
| 60 | |
|---|
| 61 | :- info(insert_all/3, [ |
|---|
| 62 | comment is 'Inserts a list of elemnts in a set, returning the resulting set.', |
|---|
| 63 | argnames is ['List', 'In', 'Out']]). |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | :- public(intersect/2). |
|---|
| 67 | |
|---|
| 68 | :- mode(intersect(+set, +set), zero_or_one). |
|---|
| 69 | |
|---|
| 70 | :- info(intersect/2, [ |
|---|
| 71 | comment is 'True if the two sets have at least one element in common.', |
|---|
| 72 | argnames is ['Set1', 'Set2']]). |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | :- public(intersection/3). |
|---|
| 76 | |
|---|
| 77 | :- mode(intersection(+set, +set, ?set), zero_or_one). |
|---|
| 78 | |
|---|
| 79 | :- info(intersection/3, [ |
|---|
| 80 | comment is 'Returns the intersection of Set1 and Set2.', |
|---|
| 81 | argnames is ['Set1', 'Set2', 'Intersection']]). |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | :- public(length/2). |
|---|
| 85 | |
|---|
| 86 | :- mode(length(+set, ?integer), zero_or_one). |
|---|
| 87 | |
|---|
| 88 | :- info(length/2, |
|---|
| 89 | [comment is 'Number of set elements.', |
|---|
| 90 | argnames is ['Set', 'Length']]). |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | :- public(member/2). |
|---|
| 94 | |
|---|
| 95 | :- mode(member(+term, +set), zero_or_one). |
|---|
| 96 | :- mode(member(-term, +set), zero_or_more). |
|---|
| 97 | |
|---|
| 98 | :- info(member/2, |
|---|
| 99 | [comment is 'Element is a member of set Set.', |
|---|
| 100 | argnames is ['Element', 'Set']]). |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | :- public(powerset/2). |
|---|
| 104 | |
|---|
| 105 | :- mode(powerset(+set, -list), one). |
|---|
| 106 | |
|---|
| 107 | :- info(powerset/2, |
|---|
| 108 | [comment is 'Returns the power set of a set, represented as a list of sets.', |
|---|
| 109 | argnames is ['Set', 'Powerset']]). |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | :- public(select/3). |
|---|
| 113 | |
|---|
| 114 | :- mode(select(?term, +set, ?set), zero_or_more). |
|---|
| 115 | |
|---|
| 116 | :- info(select/3, |
|---|
| 117 | [comment is 'Selects an element from a set, returning the set of remaining elements.', |
|---|
| 118 | argnames is ['Element', 'Set', 'Remaining']]). |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | :- public(subset/2). |
|---|
| 122 | |
|---|
| 123 | :- mode(subset(+set, +set), zero_or_one). |
|---|
| 124 | |
|---|
| 125 | :- info(subset/2, [ |
|---|
| 126 | comment is 'True if Subset is a subset of Set.', |
|---|
| 127 | argnames is ['Subset', 'Set']]). |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | :- public(subtract/3). |
|---|
| 131 | |
|---|
| 132 | :- mode(subtract(+set, +set, ?set), zero_or_one). |
|---|
| 133 | |
|---|
| 134 | :- info(subtract/3, [ |
|---|
| 135 | comment is 'True when Difference contains all and only the elements of Set1 which are not also in Set2.', |
|---|
| 136 | argnames is ['Set1', 'Set2', 'Difference']]). |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | :- public(symdiff/3). |
|---|
| 140 | |
|---|
| 141 | :- mode(symdiff(+set, +set, ?set), zero_or_one). |
|---|
| 142 | |
|---|
| 143 | :- info(symdiff/3, [ |
|---|
| 144 | comment is 'True if Difference is the symmetric difference of Set1 and Set2.', |
|---|
| 145 | argnames is ['Set1', 'Set2', 'Difference']]). |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | :- public(union/3). |
|---|
| 149 | |
|---|
| 150 | :- mode(union(+set, +set, ?set), zero_or_one). |
|---|
| 151 | |
|---|
| 152 | :- info(union/3, [ |
|---|
| 153 | comment is 'True if Union is the union of Set1 and Set2.', |
|---|
| 154 | argnames is ['Set1', 'Set2', 'Union']]). |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | :- end_protocol. |
|---|