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