src/HOL/Nitpick_Examples/Mini_Nits.thy
author blanchet
Wed Sep 21 15:55:16 2011 +0200 (2011-09-21)
changeset 45035 60d2c03d5c70
child 45062 9598cada31b3
permissions -rw-r--r--
reintroduced Minipick as Nitpick example
blanchet@45035
     1
(*  Title:      HOL/Nitpick_Examples/Mini_Nits.thy
blanchet@45035
     2
    Author:     Jasmin Blanchette, TU Muenchen
blanchet@45035
     3
    Copyright   2009-2011
blanchet@45035
     4
blanchet@45035
     5
Examples featuring Minipick, the minimalistic version of Nitpick.
blanchet@45035
     6
*)
blanchet@45035
     7
blanchet@45035
     8
header {* Examples Featuring Minipick, the Minimalistic Version of Nitpick *}
blanchet@45035
     9
blanchet@45035
    10
theory Mini_Nits
blanchet@45035
    11
imports Main
blanchet@45035
    12
uses "minipick.ML"
blanchet@45035
    13
begin
blanchet@45035
    14
blanchet@45035
    15
ML {*
blanchet@45035
    16
exception FAIL
blanchet@45035
    17
blanchet@45035
    18
val has_kodkodi = (getenv "KODKODI" <> "")
blanchet@45035
    19
blanchet@45035
    20
fun minipick n t =
blanchet@45035
    21
  map (fn k => Minipick.kodkod_problem_from_term @{context} (K k) t) (1 upto n)
blanchet@45035
    22
  |> Minipick.solve_any_kodkod_problem @{theory}
blanchet@45035
    23
fun minipick_expect expect n t =
blanchet@45035
    24
  if has_kodkodi then
blanchet@45035
    25
    if minipick n t = expect then () else raise FAIL
blanchet@45035
    26
  else
blanchet@45035
    27
    ()
blanchet@45035
    28
val none = minipick_expect "none"
blanchet@45035
    29
val genuine = minipick_expect "genuine"
blanchet@45035
    30
val unknown = minipick_expect "unknown"
blanchet@45035
    31
*}
blanchet@45035
    32
blanchet@45035
    33
ML {* genuine 1 @{prop "x = Not"} *}
blanchet@45035
    34
ML {* none 1 @{prop "\<exists>x. x = Not"} *}
blanchet@45035
    35
ML {* none 1 @{prop "\<not> False"} *}
blanchet@45035
    36
ML {* genuine 1 @{prop "\<not> True"} *}
blanchet@45035
    37
ML {* none 1 @{prop "\<not> \<not> b \<longleftrightarrow> b"} *}
blanchet@45035
    38
ML {* none 1 @{prop True} *}
blanchet@45035
    39
ML {* genuine 1 @{prop False} *}
blanchet@45035
    40
ML {* genuine 1 @{prop "True \<longleftrightarrow> False"} *}
blanchet@45035
    41
ML {* none 1 @{prop "True \<longleftrightarrow> \<not> False"} *}
blanchet@45035
    42
ML {* none 5 @{prop "\<forall>x. x = x"} *}
blanchet@45035
    43
ML {* none 5 @{prop "\<exists>x. x = x"} *}
blanchet@45035
    44
ML {* none 1 @{prop "\<forall>x. x = y"} *}
blanchet@45035
    45
ML {* genuine 2 @{prop "\<forall>x. x = y"} *}
blanchet@45035
    46
ML {* none 1 @{prop "\<exists>x. x = y"} *}
blanchet@45035
    47
ML {* none 2 @{prop "\<exists>x. x = y"} *}
blanchet@45035
    48
ML {* none 2 @{prop "\<forall>x\<Colon>'a \<times> 'a. x = x"} *}
blanchet@45035
    49
ML {* none 2 @{prop "\<exists>x\<Colon>'a \<times> 'a. x = y"} *}
blanchet@45035
    50
ML {* genuine 2 @{prop "\<forall>x\<Colon>'a \<times> 'a. x = y"} *}
blanchet@45035
    51
ML {* none 2 @{prop "\<exists>x\<Colon>'a \<times> 'a. x = y"} *}
blanchet@45035
    52
ML {* none 1 @{prop "All = Ex"} *}
blanchet@45035
    53
ML {* genuine 2 @{prop "All = Ex"} *}
blanchet@45035
    54
ML {* none 1 @{prop "All P = Ex P"} *}
blanchet@45035
    55
ML {* genuine 2 @{prop "All P = Ex P"} *}
blanchet@45035
    56
ML {* none 5 @{prop "x = y \<longrightarrow> P x = P y"} *}
blanchet@45035
    57
ML {* none 5 @{prop "(x\<Colon>'a \<times> 'a) = y \<longrightarrow> P x = P y"} *}
blanchet@45035
    58
ML {* none 2 @{prop "(x\<Colon>'a \<times> 'a) = y \<longrightarrow> P x y = P y x"} *}
blanchet@45035
    59
ML {* none 5 @{prop "\<exists>x\<Colon>'a \<times> 'a. x = y \<longrightarrow> P x = P y"} *}
blanchet@45035
    60
ML {* none 2 @{prop "(x\<Colon>'a \<Rightarrow> 'a) = y \<longrightarrow> P x = P y"} *}
blanchet@45035
    61
ML {* none 2 @{prop "\<exists>x\<Colon>'a \<Rightarrow> 'a. x = y \<longrightarrow> P x = P y"} *}
blanchet@45035
    62
ML {* genuine 1 @{prop "(op =) X = Ex"} *}
blanchet@45035
    63
ML {* none 2 @{prop "\<forall>x::'a \<Rightarrow> 'a. x = x"} *}
blanchet@45035
    64
ML {* none 1 @{prop "x = y"} *}
blanchet@45035
    65
ML {* genuine 1 @{prop "x \<longleftrightarrow> y"} *}
blanchet@45035
    66
ML {* genuine 2 @{prop "x = y"} *}
blanchet@45035
    67
ML {* genuine 1 @{prop "X \<subseteq> Y"} *}
blanchet@45035
    68
ML {* none 1 @{prop "P \<and> Q \<longleftrightarrow> Q \<and> P"} *}
blanchet@45035
    69
ML {* none 1 @{prop "P \<and> Q \<longrightarrow> P"} *}
blanchet@45035
    70
ML {* none 1 @{prop "P \<or> Q \<longleftrightarrow> Q \<or> P"} *}
blanchet@45035
    71
ML {* genuine 1 @{prop "P \<or> Q \<longrightarrow> P"} *}
blanchet@45035
    72
ML {* none 1 @{prop "(P \<longrightarrow> Q) \<longleftrightarrow> (\<not> P \<or> Q)"} *}
blanchet@45035
    73
ML {* none 5 @{prop "{a} = {a, a}"} *}
blanchet@45035
    74
ML {* genuine 2 @{prop "{a} = {a, b}"} *}
blanchet@45035
    75
ML {* genuine 1 @{prop "{a} \<noteq> {a, b}"} *}
blanchet@45035
    76
ML {* none 5 @{prop "{}\<^sup>+ = {}"} *}
blanchet@45035
    77
ML {* none 1 @{prop "{(a, b), (b, c)}\<^sup>+ = {(a, b), (a, c), (b, c)}"} *}
blanchet@45035
    78
ML {* genuine 2 @{prop "{(a, b), (b, c)}\<^sup>+ = {(a, b), (a, c), (b, c)}"} *}
blanchet@45035
    79
ML {* none 5 @{prop "a \<noteq> c \<Longrightarrow> {(a, b), (b, c)}\<^sup>+ = {(a, b), (a, c), (b, c)}"} *}
blanchet@45035
    80
ML {* none 5 @{prop "A \<union> B = (\<lambda>x. A x \<or> B x)"} *}
blanchet@45035
    81
ML {* none 5 @{prop "A \<inter> B = (\<lambda>x. A x \<and> B x)"} *}
blanchet@45035
    82
ML {* none 5 @{prop "A - B = (\<lambda>x. A x \<and> \<not> B x)"} *}
blanchet@45035
    83
ML {* none 5 @{prop "\<exists>a b. (a, b) = (b, a)"} *}
blanchet@45035
    84
ML {* genuine 2 @{prop "(a, b) = (b, a)"} *}
blanchet@45035
    85
ML {* genuine 2 @{prop "(a, b) \<noteq> (b, a)"} *}
blanchet@45035
    86
ML {* none 5 @{prop "\<exists>a b\<Colon>'a \<times> 'a. (a, b) = (b, a)"} *}
blanchet@45035
    87
ML {* genuine 2 @{prop "(a\<Colon>'a \<times> 'a, b) = (b, a)"} *}
blanchet@45035
    88
ML {* none 5 @{prop "\<exists>a b\<Colon>'a \<times> 'a \<times> 'a. (a, b) = (b, a)"} *}
blanchet@45035
    89
ML {* genuine 2 @{prop "(a\<Colon>'a \<times> 'a \<times> 'a, b) \<noteq> (b, a)"} *}
blanchet@45035
    90
ML {* none 5 @{prop "\<exists>a b\<Colon>'a \<Rightarrow> 'a. (a, b) = (b, a)"} *}
blanchet@45035
    91
ML {* genuine 1 @{prop "(a\<Colon>'a \<Rightarrow> 'a, b) \<noteq> (b, a)"} *}
blanchet@45035
    92
ML {* none 5 @{prop "fst (a, b) = a"} *}
blanchet@45035
    93
ML {* none 1 @{prop "fst (a, b) = b"} *}
blanchet@45035
    94
ML {* genuine 2 @{prop "fst (a, b) = b"} *}
blanchet@45035
    95
ML {* genuine 2 @{prop "fst (a, b) \<noteq> b"} *}
blanchet@45035
    96
ML {* none 5 @{prop "snd (a, b) = b"} *}
blanchet@45035
    97
ML {* none 1 @{prop "snd (a, b) = a"} *}
blanchet@45035
    98
ML {* genuine 2 @{prop "snd (a, b) = a"} *}
blanchet@45035
    99
ML {* genuine 2 @{prop "snd (a, b) \<noteq> a"} *}
blanchet@45035
   100
ML {* genuine 1 @{prop P} *}
blanchet@45035
   101
ML {* genuine 1 @{prop "(\<lambda>x. P) a"} *}
blanchet@45035
   102
ML {* genuine 1 @{prop "(\<lambda>x y z. P y x z) a b c"} *}
blanchet@45035
   103
ML {* none 5 @{prop "\<exists>f. f = (\<lambda>x. x) \<and> f y = y"} *}
blanchet@45035
   104
ML {* genuine 1 @{prop "\<exists>f. f p \<noteq> p \<and> (\<forall>a b. f (a, b) = (a, b))"} *}
blanchet@45035
   105
ML {* none 2 @{prop "\<exists>f. \<forall>a b. f (a, b) = (a, b)"} *}
blanchet@45035
   106
ML {* none 3 @{prop "f = (\<lambda>a b. (b, a)) \<longrightarrow> f x y = (y, x)"} *}
blanchet@45035
   107
ML {* genuine 2 @{prop "f = (\<lambda>a b. (b, a)) \<longrightarrow> f x y = (x, y)"} *}
blanchet@45035
   108
blanchet@45035
   109
end