src/HOLCF/ex/Dnat.thy
author paulson
Wed, 16 Jan 2002 17:53:22 +0100
changeset 12777 70b2651af635
parent 12035 f2ee4b5d02f2
child 14981 e73f8140af78
permissions -rw-r--r--
Isar version of ZF/AC
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     1
(*  Title:      HOLCF/Dnat.thy
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     2
    ID:         $Id$
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     3
    Author:     Franz Regensburger
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     5
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     6
Theory for the domain of natural numbers  dnat = one ++ dnat
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     7
*)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     8
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
     9
theory Dnat = HOLCF:
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    10
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    11
domain dnat = dzero | dsucc (dpred :: dnat)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    12
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    13
constdefs
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    14
  iterator :: "dnat -> ('a -> 'a) -> 'a -> 'a"
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    15
  "iterator == fix $ (LAM h n f x.
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    16
    case n of dzero => x
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    17
      | dsucc $ m => f $ (h $ m $ f $ x))"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    18
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    19
text {*
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    20
  \medskip Expand fixed point properties.
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    21
*}
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    22
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    23
ML_setup {*
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    24
bind_thm ("iterator_def2", fix_prover2 (the_context ()) (thm "iterator_def")
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    25
        "iterator = (LAM n f x. case n of dzero => x | dsucc$m => f$(iterator$m$f$x))");
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    26
*}
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    27
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    28
text {*
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    29
  \medskip Recursive properties.
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    30
*}
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    31
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    32
lemma iterator1: "iterator $ UU $ f $ x = UU"
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    33
  apply (subst iterator_def2)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    34
  apply (simp add: dnat.rews)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    35
  done
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    36
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    37
lemma iterator2: "iterator $ dzero $ f $ x = x"
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    38
  apply (subst iterator_def2)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    39
  apply (simp add: dnat.rews)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    40
  done
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    41
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    42
lemma iterator3: "n ~= UU ==> iterator $ (dsucc $ n) $ f $ x = f $ (iterator $ n $ f $ x)"
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    43
  apply (rule trans)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    44
   apply (subst iterator_def2)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    45
   apply (simp add: dnat.rews)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    46
  apply (rule refl)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    47
  done
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    48
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    49
lemmas iterator_rews = iterator1 iterator2 iterator3
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    50
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    51
lemma dnat_flat: "ALL x y::dnat. x<<y --> x=UU | x=y"
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    52
  apply (rule allI)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    53
  apply (induct_tac x rule: dnat.ind)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    54
    apply fast
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    55
   apply (rule allI)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    56
   apply (rule_tac x = y in dnat.casedist)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    57
     apply (fast intro!: UU_I)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    58
    apply simp
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    59
   apply (simp add: dnat.dist_les)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    60
  apply (rule allI)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    61
  apply (rule_tac x = y in dnat.casedist)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    62
    apply (fast intro!: UU_I)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    63
   apply (simp add: dnat.dist_les)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    64
  apply (simp (no_asm_simp) add: dnat.rews)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    65
  apply (intro strip)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    66
  apply (subgoal_tac "d << da")
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    67
   apply (erule allE)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    68
   apply (drule mp)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    69
    apply assumption
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    70
   apply (erule disjE)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    71
    apply (tactic "contr_tac 1")
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    72
   apply simp
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    73
  apply (erule (2) dnat.inverts)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    74
  done
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    75
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    76
end