src/HOLCF/ex/Dnat.thy
author wenzelm
Fri, 02 Jun 2006 20:12:59 +0200
changeset 19764 372065f34795
parent 19763 ec18656a2c10
child 21404 eb85850d3eb7
permissions -rw-r--r--
removed obsolete ML files;
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
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     4
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     5
Theory for the domain of natural numbers  dnat = one ++ dnat
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     6
*)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 16322
diff changeset
     8
theory Dnat imports HOLCF begin
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
     9
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    10
domain dnat = dzero | dsucc (dpred :: dnat)
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    11
19763
wenzelm
parents: 19550
diff changeset
    12
definition
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    13
  iterator :: "dnat -> ('a -> 'a) -> 'a -> 'a"
19763
wenzelm
parents: 19550
diff changeset
    14
  "iterator = fix $ (LAM h n f x.
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    15
    case n of dzero => x
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    16
      | dsucc $ m => f $ (h $ m $ f $ x))"
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    17
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    18
text {*
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    19
  \medskip Expand fixed point properties.
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    20
*}
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    21
19764
372065f34795 removed obsolete ML files;
wenzelm
parents: 19763
diff changeset
    22
lemma iterator_def2:
372065f34795 removed obsolete ML files;
wenzelm
parents: 19763
diff changeset
    23
  "iterator = (LAM n f x. case n of dzero => x | dsucc$m => f$(iterator$m$f$x))"
372065f34795 removed obsolete ML files;
wenzelm
parents: 19763
diff changeset
    24
  apply (rule trans)
372065f34795 removed obsolete ML files;
wenzelm
parents: 19763
diff changeset
    25
  apply (rule fix_eq2)
372065f34795 removed obsolete ML files;
wenzelm
parents: 19763
diff changeset
    26
  apply (rule iterator_def [THEN eq_reflection])
372065f34795 removed obsolete ML files;
wenzelm
parents: 19763
diff changeset
    27
  apply (rule beta_cfun)
372065f34795 removed obsolete ML files;
wenzelm
parents: 19763
diff changeset
    28
  apply simp
372065f34795 removed obsolete ML files;
wenzelm
parents: 19763
diff changeset
    29
  done
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    30
19764
372065f34795 removed obsolete ML files;
wenzelm
parents: 19763
diff changeset
    31
text {* \medskip Recursive properties. *}
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    32
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    33
lemma iterator1: "iterator $ UU $ f $ x = UU"
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    34
  apply (subst iterator_def2)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    35
  apply (simp add: dnat.rews)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    36
  done
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    37
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    38
lemma iterator2: "iterator $ dzero $ f $ x = x"
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    39
  apply (subst iterator_def2)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    40
  apply (simp add: dnat.rews)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    41
  done
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    42
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    43
lemma iterator3: "n ~= UU ==> iterator $ (dsucc $ n) $ f $ x = f $ (iterator $ n $ f $ x)"
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    44
  apply (rule trans)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    45
   apply (subst iterator_def2)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    46
   apply (simp add: dnat.rews)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    47
  apply (rule refl)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    48
  done
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    49
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    50
lemmas iterator_rews = iterator1 iterator2 iterator3
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    51
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    52
lemma dnat_flat: "ALL x y::dnat. x<<y --> x=UU | x=y"
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    53
  apply (rule allI)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    54
  apply (induct_tac x rule: dnat.ind)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    55
    apply fast
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    56
   apply (rule allI)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    57
   apply (rule_tac x = y in dnat.casedist)
19550
ae77a20f6995 update to reflect changes in inverts/injects lemmas
huffman
parents: 16417
diff changeset
    58
     apply simp
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    59
    apply simp
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    60
   apply (simp add: dnat.dist_les)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    61
  apply (rule allI)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    62
  apply (rule_tac x = y in dnat.casedist)
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    63
    apply (fast intro!: UU_I)
19550
ae77a20f6995 update to reflect changes in inverts/injects lemmas
huffman
parents: 16417
diff changeset
    64
   apply (thin_tac "ALL y. d << y --> d = UU | d = y")
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    65
   apply (simp add: dnat.dist_les)
19550
ae77a20f6995 update to reflect changes in inverts/injects lemmas
huffman
parents: 16417
diff changeset
    66
  apply (simp (no_asm_simp) add: dnat.rews dnat.injects dnat.inverts)
ae77a20f6995 update to reflect changes in inverts/injects lemmas
huffman
parents: 16417
diff changeset
    67
  apply (drule_tac x="da" in spec)
ae77a20f6995 update to reflect changes in inverts/injects lemmas
huffman
parents: 16417
diff changeset
    68
  apply simp
12035
f2ee4b5d02f2 converted theory Dnat;
wenzelm
parents: 10835
diff changeset
    69
  done
2570
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    70
24d7e8fb8261 added Classlib.* and Witness.*,
oheimb
parents:
diff changeset
    71
end