src/HOL/Quickcheck_Examples/Quickcheck_Narrowing_Examples.thy
changeset 67613 ce654b0e6d69
parent 67414 c46b3f9f79ea
child 69597 ff784d5a5bfb
equal deleted inserted replaced
67610:4939494ed791 67613:ce654b0e6d69
    39   "x > 1 --> (\<exists>y :: nat. x < y & y <= 1)"
    39   "x > 1 --> (\<exists>y :: nat. x < y & y <= 1)"
    40 quickcheck[tester = narrowing, finite_types = false, expect = counterexample]
    40 quickcheck[tester = narrowing, finite_types = false, expect = counterexample]
    41 oops
    41 oops
    42 
    42 
    43 lemma
    43 lemma
    44   "x > 2 --> (\<exists>y :: nat. x < y & y <= 2)"
    44   "x > 2 \<longrightarrow> (\<exists>y :: nat. x < y \<and> y \<le> 2)"
    45 quickcheck[tester = narrowing, finite_types = false, size = 10]
    45 quickcheck[tester = narrowing, finite_types = false, size = 10]
    46 oops
    46 oops
    47 
    47 
    48 lemma
    48 lemma
    49   "\<forall> x. \<exists> y :: nat. x > 3 --> (y < x & y > 3)"
    49   "\<forall>x. \<exists>y :: nat. x > 3 \<longrightarrow> (y < x \<and> y > 3)"
    50 quickcheck[tester = narrowing, finite_types = false, size = 7]
    50 quickcheck[tester = narrowing, finite_types = false, size = 7]
    51 oops
    51 oops
    52 
    52 
    53 text \<open>A false conjecture derived from an partial copy-n-paste of @{thm not_distinct_decomp}\<close>
    53 text \<open>A false conjecture derived from an partial copy-n-paste of @{thm not_distinct_decomp}\<close>
    54 lemma
    54 lemma
    55   "~ distinct ws ==> EX xs ys zs y. ws = xs @ [y] @ ys @ [y]"
    55   "\<not> distinct ws \<Longrightarrow> \<exists>xs ys zs y. ws = xs @ [y] @ ys @ [y]"
    56 quickcheck[tester = narrowing, finite_types = false, default_type = nat, expect = counterexample]
    56 quickcheck[tester = narrowing, finite_types = false, default_type = nat, expect = counterexample]
    57 oops
    57 oops
    58 
    58 
    59 text \<open>A false conjecture derived from theorems @{thm split_list_first} and @{thm split_list_last}\<close>  
    59 text \<open>A false conjecture derived from theorems @{thm split_list_first} and @{thm split_list_last}\<close>  
    60 lemma
    60 lemma
    61   "x : set xs ==> EX ys zs. xs = ys @ x # zs & x ~: set zs & x ~: set ys"
    61   "x \<in> set xs \<Longrightarrow> \<exists>ys zs. xs = ys @ x # zs \<and> x \<notin> set zs \<and> x \<notin> set ys"
    62 quickcheck[tester = narrowing, finite_types = false, default_type = nat, expect = counterexample]
    62 quickcheck[tester = narrowing, finite_types = false, default_type = nat, expect = counterexample]
    63 oops
    63 oops
    64 
    64 
    65 text \<open>A false conjecture derived from @{thm map_eq_Cons_conv} with a typo\<close>
    65 text \<open>A false conjecture derived from @{thm map_eq_Cons_conv} with a typo\<close>
    66 lemma
    66 lemma
    67   "(map f xs = y # ys) = (EX z zs. xs = z' # zs & f z = y & map f zs = ys)"
    67   "(map f xs = y # ys) = (\<exists>z zs. xs = z' # zs & f z = y \<and> map f zs = ys)"
    68 quickcheck[tester = narrowing, finite_types = false, default_type = nat, expect = counterexample]
    68 quickcheck[tester = narrowing, finite_types = false, default_type = nat, expect = counterexample]
    69 oops
    69 oops
    70 
    70 
    71 lemma "a # xs = ys @ [a] ==> EX zs. xs = zs @ [a] & ys = a#zs"
    71 lemma "a # xs = ys @ [a] \<Longrightarrow> \<exists>zs. xs = zs @ [a] \<and> ys = a#zs"
    72 quickcheck[narrowing, expect = counterexample]
    72 quickcheck[narrowing, expect = counterexample]
    73 quickcheck[exhaustive, random, expect = no_counterexample]
    73 quickcheck[exhaustive, random, expect = no_counterexample]
    74 oops
    74 oops
    75 
    75 
    76 subsection \<open>Simple list examples\<close>
    76 subsection \<open>Simple list examples\<close>
   214 lemma set_of':
   214 lemma set_of':
   215   "set (set_of' t) = set_of t"
   215   "set (set_of' t) = set_of t"
   216 by (induct t) auto
   216 by (induct t) auto
   217 
   217 
   218 lemma is_ord_mkt:
   218 lemma is_ord_mkt:
   219   "is_ord (MKT n l r h) = ((ALL n': set (set_of' l). n' < n) & (ALL n': set (set_of' r). n < n') & is_ord l & is_ord r)"
   219   "is_ord (MKT n l r h) = ((\<forall>n' \<in> set (set_of' l). n' < n) \<and> (\<forall>n' \<in> set (set_of' r). n < n') \<and> is_ord l \<and> is_ord r)"
   220 by (simp add: set_of')
   220 by (simp add: set_of')
   221 
   221 
   222 declare is_ord.simps(1)[code] is_ord_mkt[code]
   222 declare is_ord.simps(1)[code] is_ord_mkt[code]
   223 
   223 
   224 subsubsection \<open>Invalid Lemma due to typo in @{const l_bal}\<close>
   224 subsubsection \<open>Invalid Lemma due to typo in @{const l_bal}\<close>