src/HOL/Nitpick.thy
changeset 39365 9cab71c20613
parent 39302 d7728f65b353
child 41046 f2e94005d283
equal deleted inserted replaced
39364:61f0d36840c5 39365:9cab71c20613
    28 
    28 
    29 typedecl bisim_iterator
    29 typedecl bisim_iterator
    30 
    30 
    31 axiomatization unknown :: 'a
    31 axiomatization unknown :: 'a
    32            and is_unknown :: "'a \<Rightarrow> bool"
    32            and is_unknown :: "'a \<Rightarrow> bool"
    33            and undefined_fast_The :: 'a
       
    34            and undefined_fast_Eps :: 'a
       
    35            and bisim :: "bisim_iterator \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"
    33            and bisim :: "bisim_iterator \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"
    36            and bisim_iterator_max :: bisim_iterator
    34            and bisim_iterator_max :: bisim_iterator
    37            and Quot :: "'a \<Rightarrow> 'b"
    35            and Quot :: "'a \<Rightarrow> 'b"
    38            and safe_The :: "('a \<Rightarrow> bool) \<Rightarrow> 'a"
    36            and safe_The :: "('a \<Rightarrow> bool) \<Rightarrow> 'a"
    39            and safe_Eps :: "('a \<Rightarrow> bool) \<Rightarrow> 'a"
       
    40 
    37 
    41 datatype ('a, 'b) fin_fun = FinFun "('a \<Rightarrow> 'b)"
    38 datatype ('a, 'b) fin_fun = FinFun "('a \<Rightarrow> 'b)"
    42 datatype ('a, 'b) fun_box = FunBox "('a \<Rightarrow> 'b)"
    39 datatype ('a, 'b) fun_box = FunBox "('a \<Rightarrow> 'b)"
    43 datatype ('a, 'b) pair_box = PairBox 'a 'b
    40 datatype ('a, 'b) pair_box = PairBox 'a 'b
    44 
    41 
    93 definition wfrec' ::  "('a \<times> 'a \<Rightarrow> bool) \<Rightarrow> (('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b" where
    90 definition wfrec' ::  "('a \<times> 'a \<Rightarrow> bool) \<Rightarrow> (('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b" where
    94 "wfrec' R F x \<equiv> if wf R then wf_wfrec' R F x
    91 "wfrec' R F x \<equiv> if wf R then wf_wfrec' R F x
    95                 else THE y. wfrec_rel R (%f x. F (Recdef.cut f R x) x) x y"
    92                 else THE y. wfrec_rel R (%f x. F (Recdef.cut f R x) x) x y"
    96 
    93 
    97 definition card' :: "('a \<Rightarrow> bool) \<Rightarrow> nat" where
    94 definition card' :: "('a \<Rightarrow> bool) \<Rightarrow> nat" where
    98 "card' A \<equiv> if finite A then length (safe_Eps (\<lambda>xs. set xs = A \<and> distinct xs)) else 0"
    95 "card' A \<equiv> if finite A then length (SOME xs. set xs = A \<and> distinct xs) else 0"
    99 
    96 
   100 definition setsum' :: "('a \<Rightarrow> 'b\<Colon>comm_monoid_add) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'b" where
    97 definition setsum' :: "('a \<Rightarrow> 'b\<Colon>comm_monoid_add) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'b" where
   101 "setsum' f A \<equiv> if finite A then listsum (map f (safe_Eps (\<lambda>xs. set xs = A \<and> distinct xs))) else 0"
    98 "setsum' f A \<equiv> if finite A then listsum (map f (SOME xs. set xs = A \<and> distinct xs)) else 0"
   102 
    99 
   103 inductive fold_graph' :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'b \<Rightarrow> bool" where
   100 inductive fold_graph' :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'b \<Rightarrow> bool" where
   104 "fold_graph' f z {} z" |
   101 "fold_graph' f z {} z" |
   105 "\<lbrakk>x \<in> A; fold_graph' f z (A - {x}) y\<rbrakk> \<Longrightarrow> fold_graph' f z A (f x y)"
   102 "\<lbrakk>x \<in> A; fold_graph' f z (A - {x}) y\<rbrakk> \<Longrightarrow> fold_graph' f z A (f x y)"
   106 
   103 
   237 use "Tools/Nitpick/nitpick_isar.ML"
   234 use "Tools/Nitpick/nitpick_isar.ML"
   238 use "Tools/Nitpick/nitpick_tests.ML"
   235 use "Tools/Nitpick/nitpick_tests.ML"
   239 
   236 
   240 setup {* Nitpick_Isar.setup *}
   237 setup {* Nitpick_Isar.setup *}
   241 
   238 
   242 hide_const (open) unknown is_unknown undefined_fast_The undefined_fast_Eps bisim 
   239 hide_const (open) unknown is_unknown bisim bisim_iterator_max Quot safe_The
   243     bisim_iterator_max Quot safe_The safe_Eps FinFun FunBox PairBox Word refl'
   240     FinFun FunBox PairBox Word refl' wf' wf_wfrec wf_wfrec' wfrec' card' setsum'
   244     wf' wf_wfrec wf_wfrec' wfrec' card' setsum' fold_graph' nat_gcd nat_lcm
   241     fold_graph' nat_gcd nat_lcm int_gcd int_lcm Frac Abs_Frac Rep_Frac zero_frac
   245     int_gcd int_lcm Frac Abs_Frac Rep_Frac zero_frac one_frac num denom
   242     one_frac num denom norm_frac frac plus_frac times_frac uminus_frac
   246     norm_frac frac plus_frac times_frac uminus_frac number_of_frac inverse_frac
   243     number_of_frac inverse_frac less_frac less_eq_frac of_frac
   247     less_frac less_eq_frac of_frac
       
   248 hide_type (open) bisim_iterator fin_fun fun_box pair_box unsigned_bit signed_bit
   244 hide_type (open) bisim_iterator fin_fun fun_box pair_box unsigned_bit signed_bit
   249     word
   245     word
   250 hide_fact (open) If_def Ex1_def rtrancl_def rtranclp_def tranclp_def refl'_def
   246 hide_fact (open) If_def Ex1_def rtrancl_def rtranclp_def tranclp_def refl'_def
   251     wf'_def wf_wfrec'_def wfrec'_def card'_def setsum'_def fold_graph'_def
   247     wf'_def wf_wfrec'_def wfrec'_def card'_def setsum'_def fold_graph'_def
   252     The_psimp Eps_psimp unit_case_def nat_case_def list_size_simp nat_gcd_def
   248     The_psimp Eps_psimp unit_case_def nat_case_def list_size_simp nat_gcd_def