src/HOL/Hyperreal/Fact.thy
author nipkow
Wed Aug 18 11:09:40 2004 +0200 (2004-08-18)
changeset 15140 322485b816ac
parent 15131 c69542757a4d
child 15241 a3949068537e
permissions -rw-r--r--
import -> imports
     1 (*  Title       : Fact.thy
     2     Author      : Jacques D. Fleuriot
     3     Copyright   : 1998  University of Cambridge
     4     Conversion to Isar and new proofs by Lawrence C Paulson, 2004
     5 *)
     6 
     7 header{*Factorial Function*}
     8 
     9 theory Fact
    10 imports Real
    11 begin
    12 
    13 consts fact :: "nat => nat"
    14 primrec
    15    fact_0:     "fact 0 = 1"
    16    fact_Suc:   "fact (Suc n) = (Suc n) * fact n"
    17 
    18 
    19 lemma fact_gt_zero [simp]: "0 < fact n"
    20 by (induct "n", auto)
    21 
    22 lemma fact_not_eq_zero [simp]: "fact n \<noteq> 0"
    23 by simp
    24 
    25 lemma real_of_nat_fact_not_zero [simp]: "real (fact n) \<noteq> 0"
    26 by auto
    27 
    28 lemma real_of_nat_fact_gt_zero [simp]: "0 < real(fact n)"
    29 by auto
    30 
    31 lemma real_of_nat_fact_ge_zero [simp]: "0 \<le> real(fact n)"
    32 by simp
    33 
    34 lemma fact_ge_one [simp]: "1 \<le> fact n"
    35 by (induct "n", auto)
    36 
    37 lemma fact_mono: "m \<le> n ==> fact m \<le> fact n"
    38 apply (drule le_imp_less_or_eq)
    39 apply (auto dest!: less_imp_Suc_add)
    40 apply (induct_tac "k", auto)
    41 done
    42 
    43 text{*Note that @{term "fact 0 = fact 1"}*}
    44 lemma fact_less_mono: "[| 0 < m; m < n |] ==> fact m < fact n"
    45 apply (drule_tac m = m in less_imp_Suc_add, auto)
    46 apply (induct_tac "k", auto)
    47 done
    48 
    49 lemma inv_real_of_nat_fact_gt_zero [simp]: "0 < inverse (real (fact n))"
    50 by (auto simp add: positive_imp_inverse_positive)
    51 
    52 lemma inv_real_of_nat_fact_ge_zero [simp]: "0 \<le> inverse (real (fact n))"
    53 by (auto intro: order_less_imp_le)
    54 
    55 lemma fact_diff_Suc [rule_format]:
    56      "\<forall>m. n < Suc m --> fact (Suc m - n) = (Suc m - n) * fact (m - n)"
    57 apply (induct n, auto)
    58 apply (drule_tac x = "m - 1" in spec, auto)
    59 done
    60 
    61 lemma fact_num0 [simp]: "fact 0 = 1"
    62 by auto
    63 
    64 lemma fact_num_eq_if: "fact m = (if m=0 then 1 else m * fact (m - 1))"
    65 by (case_tac "m", auto)
    66 
    67 lemma fact_add_num_eq_if:
    68      "fact (m+n) = (if (m+n = 0) then 1 else (m+n) * (fact (m + n - 1)))"
    69 by (case_tac "m+n", auto)
    70 
    71 lemma fact_add_num_eq_if2:
    72      "fact (m+n) = (if m=0 then fact n else (m+n) * (fact ((m - 1) + n)))"
    73 by (case_tac "m", auto)
    74 
    75 
    76 end