equal
deleted
inserted
replaced
55 (\<lambda>l. next \<circ>\<rightarrow> (\<lambda>v. Pair (v + l * 2147483561))) 1 |
55 (\<lambda>l. next \<circ>\<rightarrow> (\<lambda>v. Pair (v + l * 2147483561))) 1 |
56 \<circ>\<rightarrow> (\<lambda>v. Pair (v mod k))" |
56 \<circ>\<rightarrow> (\<lambda>v. Pair (v mod k))" |
57 |
57 |
58 lemma range: |
58 lemma range: |
59 "k > 0 \<Longrightarrow> fst (range k s) < k" |
59 "k > 0 \<Longrightarrow> fst (range k s) < k" |
60 by (simp add: range_def scomp_apply split_def del: log.simps iterate.simps) |
60 by (simp add: range_def split_def del: log.simps iterate.simps) |
61 |
61 |
62 definition select :: "'a list \<Rightarrow> seed \<Rightarrow> 'a \<times> seed" where |
62 definition select :: "'a list \<Rightarrow> seed \<Rightarrow> 'a \<times> seed" where |
63 "select xs = range (Code_Numeral.of_nat (length xs)) |
63 "select xs = range (Code_Numeral.of_nat (length xs)) |
64 \<circ>\<rightarrow> (\<lambda>k. Pair (nth xs (Code_Numeral.nat_of k)))" |
64 \<circ>\<rightarrow> (\<lambda>k. Pair (nth xs (Code_Numeral.nat_of k)))" |
65 |
65 |
71 with range have |
71 with range have |
72 "fst (range (Code_Numeral.of_nat (length xs)) s) < Code_Numeral.of_nat (length xs)" by best |
72 "fst (range (Code_Numeral.of_nat (length xs)) s) < Code_Numeral.of_nat (length xs)" by best |
73 then have |
73 then have |
74 "Code_Numeral.nat_of (fst (range (Code_Numeral.of_nat (length xs)) s)) < length xs" by simp |
74 "Code_Numeral.nat_of (fst (range (Code_Numeral.of_nat (length xs)) s)) < length xs" by simp |
75 then show ?thesis |
75 then show ?thesis |
76 by (simp add: scomp_apply split_beta select_def) |
76 by (simp add: split_beta select_def) |
77 qed |
77 qed |
78 |
78 |
79 primrec pick :: "(code_numeral \<times> 'a) list \<Rightarrow> code_numeral \<Rightarrow> 'a" where |
79 primrec pick :: "(code_numeral \<times> 'a) list \<Rightarrow> code_numeral \<Rightarrow> 'a" where |
80 "pick (x # xs) i = (if i < fst x then snd x else pick xs (i - fst x))" |
80 "pick (x # xs) i = (if i < fst x then snd x else pick xs (i - fst x))" |
81 |
81 |
186 |
186 |
187 no_notation fcomp (infixl "\<circ>>" 60) |
187 no_notation fcomp (infixl "\<circ>>" 60) |
188 no_notation scomp (infixl "\<circ>\<rightarrow>" 60) |
188 no_notation scomp (infixl "\<circ>\<rightarrow>" 60) |
189 |
189 |
190 end |
190 end |
191 |
|