equal
deleted
inserted
replaced
69 "S\<^sub>1p w \<Longrightarrow> w = []" |
69 "S\<^sub>1p w \<Longrightarrow> w = []" |
70 quickcheck[tester = smart_exhaustive, iterations=1] |
70 quickcheck[tester = smart_exhaustive, iterations=1] |
71 oops |
71 oops |
72 |
72 |
73 theorem S\<^sub>1_sound: |
73 theorem S\<^sub>1_sound: |
74 "S\<^sub>1p w \<Longrightarrow> length (filter (\<lambda>x. x=a) w) = length (filter (\<lambda>x. x=b) w)" |
74 "S\<^sub>1p w \<Longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]" |
75 quickcheck[tester=smart_exhaustive, size=15] |
75 quickcheck[tester=smart_exhaustive, size=15] |
76 oops |
76 oops |
77 |
77 |
78 |
78 |
79 inductive_set S\<^sub>2 and A\<^sub>2 and B\<^sub>2 where |
79 inductive_set S\<^sub>2 and A\<^sub>2 and B\<^sub>2 where |
111 "w \<in> S\<^sub>2 ==> length [x \<leftarrow> w. x = a] <= Suc (Suc 0)" |
111 "w \<in> S\<^sub>2 ==> length [x \<leftarrow> w. x = a] <= Suc (Suc 0)" |
112 quickcheck[generator=predicate_compile, size = 10, iterations = 1] |
112 quickcheck[generator=predicate_compile, size = 10, iterations = 1] |
113 oops |
113 oops |
114 *) |
114 *) |
115 theorem S\<^sub>2_sound: |
115 theorem S\<^sub>2_sound: |
116 "S\<^sub>2p w \<longrightarrow> length (filter (\<lambda>x. x=a) w) = length (filter (\<lambda>x. x=b) w)" |
116 "S\<^sub>2p w \<longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]" |
117 quickcheck[tester=smart_exhaustive, size=5, iterations=10] |
117 quickcheck[tester=smart_exhaustive, size=5, iterations=10] |
118 oops |
118 oops |
119 |
119 |
120 inductive_set S\<^sub>3 and A\<^sub>3 and B\<^sub>3 where |
120 inductive_set S\<^sub>3 and A\<^sub>3 and B\<^sub>3 where |
121 "[] \<in> S\<^sub>3" |
121 "[] \<in> S\<^sub>3" |
131 values 10 "{x. S\<^sub>3 x}" |
131 values 10 "{x. S\<^sub>3 x}" |
132 *) |
132 *) |
133 |
133 |
134 |
134 |
135 lemma S\<^sub>3_sound: |
135 lemma S\<^sub>3_sound: |
136 "S\<^sub>3p w \<longrightarrow> length (filter (\<lambda>x. x=a) w) = length (filter (\<lambda>x. x=b) w)" |
136 "S\<^sub>3p w \<longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]" |
137 quickcheck[tester=smart_exhaustive, size=10, iterations=10] |
137 quickcheck[tester=smart_exhaustive, size=10, iterations=10] |
138 oops |
138 oops |
139 |
139 |
140 lemma "\<not> (length w > 2) \<or> \<not> (length (filter (\<lambda>x. x=a) w) = length (filter (\<lambda>x. x=b) w))" |
140 lemma "\<not> (length w > 2) \<or> \<not> (length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b])" |
141 quickcheck[size=10, tester = smart_exhaustive] |
141 quickcheck[size=10, tester = smart_exhaustive] |
142 oops |
142 oops |
143 |
143 |
144 theorem S\<^sub>3_complete: |
144 theorem S\<^sub>3_complete: |
145 "length (filter (\<lambda>x. x=a) w) = length (filter (\<lambda>x. x=b) w) \<longrightarrow> S\<^sub>3p w" |
145 "length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. b = x] \<longrightarrow> S\<^sub>3p w" |
146 (*quickcheck[generator=SML]*) |
146 (*quickcheck[generator=SML]*) |
147 quickcheck[tester=smart_exhaustive, size=10, iterations=100] |
147 quickcheck[tester=smart_exhaustive, size=10, iterations=100] |
148 oops |
148 oops |
149 |
149 |
150 |
150 |
156 | "\<lbrakk>v \<in> A\<^sub>4; w \<in> A\<^sub>4\<rbrakk> \<Longrightarrow> b # v @ w \<in> A\<^sub>4" |
156 | "\<lbrakk>v \<in> A\<^sub>4; w \<in> A\<^sub>4\<rbrakk> \<Longrightarrow> b # v @ w \<in> A\<^sub>4" |
157 | "w \<in> S\<^sub>4 \<Longrightarrow> b # w \<in> B\<^sub>4" |
157 | "w \<in> S\<^sub>4 \<Longrightarrow> b # w \<in> B\<^sub>4" |
158 | "\<lbrakk>v \<in> B\<^sub>4; w \<in> B\<^sub>4\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^sub>4" |
158 | "\<lbrakk>v \<in> B\<^sub>4; w \<in> B\<^sub>4\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^sub>4" |
159 |
159 |
160 theorem S\<^sub>4_sound: |
160 theorem S\<^sub>4_sound: |
161 "S\<^sub>4p w \<longrightarrow> length (filter (\<lambda>x. x=a) w) = length (filter (\<lambda>x. x=b) w)" |
161 "S\<^sub>4p w \<longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]" |
162 quickcheck[tester = smart_exhaustive, size=5, iterations=1] |
162 quickcheck[tester = smart_exhaustive, size=5, iterations=1] |
163 oops |
163 oops |
164 |
164 |
165 theorem S\<^sub>4_complete: |
165 theorem S\<^sub>4_complete: |
166 "length (filter (\<lambda>x. x=a) w) = length (filter (\<lambda>x. x=b) w) \<longrightarrow> S\<^sub>4p w" |
166 "length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b] \<longrightarrow> S\<^sub>4p w" |
167 quickcheck[tester = smart_exhaustive, size=5, iterations=1] |
167 quickcheck[tester = smart_exhaustive, size=5, iterations=1] |
168 oops |
168 oops |
169 |
169 |
170 hide_const a b |
170 hide_const a b |
171 |
171 |
299 "matrix M m n \<and> length v = n"} must hold. |
299 "matrix M m n \<and> length v = n"} must hold. |
300 \<close> |
300 \<close> |
301 |
301 |
302 subsection "Compressed matrix" |
302 subsection "Compressed matrix" |
303 |
303 |
304 definition "sparsify xs = filter (\<lambda>i. snd i \<noteq> 0) (zip [0..<length xs] xs)" |
304 definition "sparsify xs = [i \<leftarrow> zip [0..<length xs] xs. snd i \<noteq> 0]" |
305 (* |
305 (* |
306 lemma sparsify_length: "(i, x) \<in> set (sparsify xs) \<Longrightarrow> i < length xs" |
306 lemma sparsify_length: "(i, x) \<in> set (sparsify xs) \<Longrightarrow> i < length xs" |
307 by (auto simp: sparsify_def set_zip) |
307 by (auto simp: sparsify_def set_zip) |
308 |
308 |
309 lemma sum_list_sparsify[simp]: |
309 lemma sum_list_sparsify[simp]: |