33257
|
1 |
theory Predicate_Compile_Quickcheck_ex
|
|
2 |
imports Predicate_Compile_Quickcheck
|
|
3 |
Predicate_Compile_Alternative_Defs
|
|
4 |
begin
|
|
5 |
|
|
6 |
section {* Sets *}
|
|
7 |
|
|
8 |
|
|
9 |
section {* Context Free Grammar *}
|
|
10 |
|
|
11 |
datatype alphabet = a | b
|
|
12 |
|
|
13 |
inductive_set S\<^isub>1 and A\<^isub>1 and B\<^isub>1 where
|
|
14 |
"[] \<in> S\<^isub>1"
|
|
15 |
| "w \<in> A\<^isub>1 \<Longrightarrow> b # w \<in> S\<^isub>1"
|
|
16 |
| "w \<in> B\<^isub>1 \<Longrightarrow> a # w \<in> S\<^isub>1"
|
|
17 |
| "w \<in> S\<^isub>1 \<Longrightarrow> a # w \<in> A\<^isub>1"
|
|
18 |
| "w \<in> S\<^isub>1 \<Longrightarrow> b # w \<in> S\<^isub>1"
|
|
19 |
| "\<lbrakk>v \<in> B\<^isub>1; v \<in> B\<^isub>1\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>1"
|
|
20 |
|
|
21 |
theorem S\<^isub>1_sound:
|
|
22 |
"w \<in> S\<^isub>1p \<Longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]"
|
|
23 |
(*quickcheck[generator=predicate_compile, size=15]*)
|
|
24 |
oops
|
|
25 |
|
|
26 |
|
|
27 |
inductive_set S\<^isub>2 and A\<^isub>2 and B\<^isub>2 where
|
|
28 |
"[] \<in> S\<^isub>2"
|
|
29 |
| "w \<in> A\<^isub>2 \<Longrightarrow> b # w \<in> S\<^isub>2"
|
|
30 |
| "w \<in> B\<^isub>2 \<Longrightarrow> a # w \<in> S\<^isub>2"
|
|
31 |
| "w \<in> S\<^isub>2 \<Longrightarrow> a # w \<in> A\<^isub>2"
|
|
32 |
| "w \<in> S\<^isub>2 \<Longrightarrow> b # w \<in> B\<^isub>2"
|
|
33 |
| "\<lbrakk>v \<in> B\<^isub>2; v \<in> B\<^isub>2\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>2"
|
|
34 |
|
33375
|
35 |
code_pred [inductify, random] S\<^isub>2 .
|
|
36 |
thm S\<^isub>2.random_equation
|
|
37 |
thm A\<^isub>2.random_equation
|
|
38 |
thm B\<^isub>2.random_equation
|
33257
|
39 |
|
|
40 |
values [random] 10 "{x. S\<^isub>2 x}"
|
|
41 |
|
|
42 |
lemma "w \<in> S\<^isub>2 ==> w \<noteq> [] ==> w \<noteq> [b, a] ==> w \<in> {}"
|
|
43 |
quickcheck[generator=predicate_compile]
|
|
44 |
oops
|
|
45 |
|
|
46 |
lemma "[x <- w. x = a] = []"
|
|
47 |
quickcheck[generator=predicate_compile]
|
|
48 |
oops
|
|
49 |
|
|
50 |
|
|
51 |
lemma "length ([x \<leftarrow> w. x = a]) = (0::nat)"
|
|
52 |
(*quickcheck[generator=predicate_compile]*)
|
|
53 |
oops
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
lemma
|
|
58 |
"w \<in> S\<^isub>2 ==> length [x \<leftarrow> w. x = a] < Suc (Suc 0)"
|
|
59 |
(*quickcheck[generator=predicate_compile]*)
|
|
60 |
oops
|
|
61 |
|
|
62 |
|
|
63 |
theorem S\<^isub>2_sound:
|
|
64 |
"w \<in> S\<^isub>2 \<longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]"
|
|
65 |
(*quickcheck[generator=predicate_compile, size=15, iterations=100]*)
|
|
66 |
oops
|
|
67 |
|
|
68 |
inductive_set S\<^isub>3 and A\<^isub>3 and B\<^isub>3 where
|
|
69 |
"[] \<in> S\<^isub>3"
|
|
70 |
| "w \<in> A\<^isub>3 \<Longrightarrow> b # w \<in> S\<^isub>3"
|
|
71 |
| "w \<in> B\<^isub>3 \<Longrightarrow> a # w \<in> S\<^isub>3"
|
|
72 |
| "w \<in> S\<^isub>3 \<Longrightarrow> a # w \<in> A\<^isub>3"
|
|
73 |
| "w \<in> S\<^isub>3 \<Longrightarrow> b # w \<in> B\<^isub>3"
|
|
74 |
| "\<lbrakk>v \<in> B\<^isub>3; w \<in> B\<^isub>3\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>3"
|
|
75 |
|
|
76 |
code_pred [inductify] S\<^isub>3 .
|
|
77 |
thm S\<^isub>3.equation
|
|
78 |
|
|
79 |
values 10 "{x. S\<^isub>3 x}"
|
|
80 |
|
|
81 |
lemma S\<^isub>3_sound:
|
|
82 |
"w \<in> S\<^isub>3 \<longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]"
|
|
83 |
(*quickcheck[generator=predicate_compile, size=10, iterations=1]*)
|
|
84 |
oops
|
|
85 |
|
|
86 |
|
|
87 |
lemma "\<not> (length w > 2) \<or> \<not> (length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b])"
|
|
88 |
(*quickcheck[size=10, generator = pred_compile]*)
|
|
89 |
oops
|
|
90 |
|
|
91 |
theorem S\<^isub>3_complete:
|
|
92 |
"length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. b = x] \<longrightarrow> w \<in> S\<^isub>3"
|
|
93 |
(*quickcheck[generator=SML]*)
|
|
94 |
(*quickcheck[generator=predicate_compile, size=10, iterations=100]*)
|
|
95 |
oops
|
|
96 |
|
|
97 |
|
|
98 |
inductive_set S\<^isub>4 and A\<^isub>4 and B\<^isub>4 where
|
|
99 |
"[] \<in> S\<^isub>4"
|
|
100 |
| "w \<in> A\<^isub>4 \<Longrightarrow> b # w \<in> S\<^isub>4"
|
|
101 |
| "w \<in> B\<^isub>4 \<Longrightarrow> a # w \<in> S\<^isub>4"
|
|
102 |
| "w \<in> S\<^isub>4 \<Longrightarrow> a # w \<in> A\<^isub>4"
|
|
103 |
| "\<lbrakk>v \<in> A\<^isub>4; w \<in> A\<^isub>4\<rbrakk> \<Longrightarrow> b # v @ w \<in> A\<^isub>4"
|
|
104 |
| "w \<in> S\<^isub>4 \<Longrightarrow> b # w \<in> B\<^isub>4"
|
|
105 |
| "\<lbrakk>v \<in> B\<^isub>4; w \<in> B\<^isub>4\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>4"
|
|
106 |
|
|
107 |
theorem S\<^isub>4_sound:
|
|
108 |
"w \<in> S\<^isub>4 \<longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]"
|
|
109 |
(*quickcheck[generator = predicate_compile, size=2, iterations=1]*)
|
|
110 |
oops
|
|
111 |
|
|
112 |
theorem S\<^isub>4_complete:
|
|
113 |
"length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b] \<longrightarrow> w \<in> S\<^isub>4"
|
|
114 |
(*quickcheck[generator = pred_compile, size=5, iterations=1]*)
|
|
115 |
oops
|
|
116 |
|
|
117 |
|
|
118 |
end |