src/HOL/Old_Number_Theory/IntFact.thy
author krauss
Tue Mar 02 12:26:50 2010 +0100 (2010-03-02)
changeset 35440 bdf8ad377877
parent 32479 521cc9bf2958
child 38159 e9b4835a54ee
permissions -rw-r--r--
killed more recdefs
     1 (*  Author:     Thomas M. Rasmussen
     2     Copyright   2000  University of Cambridge
     3 *)
     4 
     5 header {* Factorial on integers *}
     6 
     7 theory IntFact imports IntPrimes begin
     8 
     9 text {*
    10   Factorial on integers and recursively defined set including all
    11   Integers from @{text 2} up to @{text a}.  Plus definition of product
    12   of finite set.
    13 
    14   \bigskip
    15 *}
    16 
    17 fun
    18   zfact :: "int => int"
    19 where
    20   "zfact n = (if n \<le> 0 then 1 else n * zfact (n - 1))"
    21 
    22 fun
    23   d22set :: "int => int set"
    24 where
    25   "d22set a = (if 1 < a then insert a (d22set (a - 1)) else {})"
    26 
    27 
    28 text {*
    29   \medskip @{term d22set} --- recursively defined set including all
    30   integers from @{text 2} up to @{text a}
    31 *}
    32 
    33 declare d22set.simps [simp del]
    34 
    35 
    36 lemma d22set_induct:
    37   assumes "!!a. P {} a"
    38     and "!!a. 1 < (a::int) ==> P (d22set (a - 1)) (a - 1) ==> P (d22set a) a"
    39   shows "P (d22set u) u"
    40   apply (rule d22set.induct)
    41   apply (case_tac "1 < a")
    42    apply (rule_tac assms)
    43     apply (simp_all (no_asm_simp))
    44   apply (simp_all (no_asm_simp) add: d22set.simps assms)
    45   done
    46 
    47 lemma d22set_g_1 [rule_format]: "b \<in> d22set a --> 1 < b"
    48   apply (induct a rule: d22set_induct)
    49    apply simp
    50   apply (subst d22set.simps)
    51   apply auto
    52   done
    53 
    54 lemma d22set_le [rule_format]: "b \<in> d22set a --> b \<le> a"
    55   apply (induct a rule: d22set_induct)
    56   apply simp
    57    apply (subst d22set.simps)
    58    apply auto
    59   done
    60 
    61 lemma d22set_le_swap: "a < b ==> b \<notin> d22set a"
    62   by (auto dest: d22set_le)
    63 
    64 lemma d22set_mem: "1 < b \<Longrightarrow> b \<le> a \<Longrightarrow> b \<in> d22set a"
    65   apply (induct a rule: d22set.induct)
    66   apply auto
    67   apply (subst d22set.simps)
    68   apply (case_tac "b < a", auto)
    69   done
    70 
    71 lemma d22set_fin: "finite (d22set a)"
    72   apply (induct a rule: d22set_induct)
    73    prefer 2
    74    apply (subst d22set.simps)
    75    apply auto
    76   done
    77 
    78 
    79 declare zfact.simps [simp del]
    80 
    81 lemma d22set_prod_zfact: "\<Prod>(d22set a) = zfact a"
    82   apply (induct a rule: d22set.induct)
    83   apply (subst d22set.simps)
    84   apply (subst zfact.simps)
    85   apply (case_tac "1 < a")
    86    prefer 2
    87    apply (simp add: d22set.simps zfact.simps)
    88   apply (simp add: d22set_fin d22set_le_swap)
    89   done
    90 
    91 end