123 | "unionl xs ys = foldr insertl xs ys" |
123 | "unionl xs ys = foldr insertl xs ys" |
124 by pat_completeness auto |
124 by pat_completeness auto |
125 termination by lexicographic_order |
125 termination by lexicographic_order |
126 |
126 |
127 lemmas unionl_def = unionl.simps(2) |
127 lemmas unionl_def = unionl.simps(2) |
128 declare unionl.simps[code] |
|
129 |
128 |
130 function intersect :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
129 function intersect :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
131 where |
130 where |
132 "intersect [] ys = []" |
131 "intersect [] ys = []" |
133 | "intersect xs [] = []" |
132 | "intersect xs [] = []" |
134 | "intersect xs ys = filter (member xs) ys" |
133 | "intersect xs ys = filter (member xs) ys" |
135 by pat_completeness auto |
134 by pat_completeness auto |
136 termination by lexicographic_order |
135 termination by lexicographic_order |
137 |
136 |
138 lemmas intersect_def = intersect.simps(3) |
137 lemmas intersect_def = intersect.simps(3) |
139 declare intersect.simps[code] |
|
140 |
138 |
141 function subtract :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
139 function subtract :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
142 where |
140 where |
143 "subtract [] ys = ys" |
141 "subtract [] ys = ys" |
144 | "subtract xs [] = []" |
142 | "subtract xs [] = []" |
145 | "subtract xs ys = foldr remove1 xs ys" |
143 | "subtract xs ys = foldr remove1 xs ys" |
146 by pat_completeness auto |
144 by pat_completeness auto |
147 termination by lexicographic_order |
145 termination by lexicographic_order |
148 |
146 |
149 lemmas subtract_def = subtract.simps(3) |
147 lemmas subtract_def = subtract.simps(3) |
150 declare subtract.simps[code] |
|
151 |
148 |
152 function map_distinct :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a list \<Rightarrow> 'b list" |
149 function map_distinct :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a list \<Rightarrow> 'b list" |
153 where |
150 where |
154 "map_distinct f [] = []" |
151 "map_distinct f [] = []" |
155 | "map_distinct f xs = foldr (insertl o f) xs []" |
152 | "map_distinct f xs = foldr (insertl o f) xs []" |
156 by pat_completeness auto |
153 by pat_completeness auto |
157 termination by lexicographic_order |
154 termination by lexicographic_order |
158 |
155 |
159 lemmas map_distinct_def = map_distinct.simps(2) |
156 lemmas map_distinct_def = map_distinct.simps(2) |
160 declare map_distinct.simps[code] |
|
161 |
157 |
162 function unions :: "'a list list \<Rightarrow> 'a list" |
158 function unions :: "'a list list \<Rightarrow> 'a list" |
163 where |
159 where |
164 "unions [] = []" |
160 "unions [] = []" |
165 "unions xs = foldr unionl xs []" |
161 "unions xs = foldr unionl xs []" |
166 by pat_completeness auto |
162 by pat_completeness auto |
167 termination by lexicographic_order |
163 termination by lexicographic_order |
168 |
164 |
169 lemmas unions_def = unions.simps(2) |
165 lemmas unions_def = unions.simps(2) |
170 declare unions.simps[code] |
|
171 |
166 |
172 consts intersects :: "'a list list \<Rightarrow> 'a list" |
167 consts intersects :: "'a list list \<Rightarrow> 'a list" |
173 primrec |
168 primrec |
174 "intersects (x#xs) = foldr intersect xs x" |
169 "intersects (x#xs) = foldr intersect xs x" |
175 |
170 |