src/HOL/ex/Simult.thy
author clasohm
Tue, 30 Jan 1996 15:24:36 +0100
changeset 1465 5d7a7e439cec
parent 1381 57777949b2f8
child 1476 608483c2122a
permissions -rw-r--r--
expanded tabs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/ex/Simult
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     5
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     6
A simultaneous recursive type definition: trees & forests
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     7
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     8
This is essentially the same data structure that on ex/term.ML, which is
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     9
simpler because it uses list as a new type former.  The approach in this
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    10
file may be superior for other simultaneous recursions.
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    11
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    12
The inductive definition package does not help defining this sort of mutually
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    13
recursive data structure because it uses Inl, Inr instead of In0, In1.
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    14
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    15
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    16
Simult = SList +
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    17
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    18
types    'a tree
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    19
         'a forest
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    20
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    21
arities  tree,forest :: (term)term
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    22
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    23
consts
1376
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    24
  TF          :: 'a item set => 'a item set
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    25
  FNIL        :: 'a item
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    26
  TCONS,FCONS :: ['a item, 'a item] => 'a item
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    27
  Rep_Tree    :: 'a tree => 'a item
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    28
  Abs_Tree    :: 'a item => 'a tree
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    29
  Rep_Forest  :: 'a forest => 'a item
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    30
  Abs_Forest  :: 'a item => 'a forest
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    31
  Tcons       :: ['a, 'a forest] => 'a tree
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    32
  Fcons       :: ['a tree, 'a forest] => 'a forest
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1151
diff changeset
    33
  Fnil        :: 'a forest
1381
57777949b2f8 removed some more quotes
clasohm
parents: 1376
diff changeset
    34
  TF_rec      :: ['a item, ['a item , 'a item, 'b]=>'b,     
57777949b2f8 removed some more quotes
clasohm
parents: 1376
diff changeset
    35
                 'b, ['a item , 'a item, 'b, 'b]=>'b] => 'b
57777949b2f8 removed some more quotes
clasohm
parents: 1376
diff changeset
    36
  tree_rec    :: ['a tree, ['a, 'a forest, 'b]=>'b,          
57777949b2f8 removed some more quotes
clasohm
parents: 1376
diff changeset
    37
                 'b, ['a tree, 'a forest, 'b, 'b]=>'b] => 'b
57777949b2f8 removed some more quotes
clasohm
parents: 1376
diff changeset
    38
  forest_rec  :: ['a forest, ['a, 'a forest, 'b]=>'b,        
57777949b2f8 removed some more quotes
clasohm
parents: 1376
diff changeset
    39
                  'b, ['a tree, 'a forest, 'b, 'b]=>'b] => 'b
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    40
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    41
defs
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    42
     (*the concrete constants*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    43
  TCONS_def 	"TCONS M N == In0(M $ N)"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    44
  FNIL_def	"FNIL      == In1(NIL)"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    45
  FCONS_def	"FCONS M N == In1(CONS M N)"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    46
     (*the abstract constants*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    47
  Tcons_def 	"Tcons a ts == Abs_Tree(TCONS (Leaf a) (Rep_Forest ts))"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    48
  Fnil_def  	"Fnil       == Abs_Forest(FNIL)"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    49
  Fcons_def 	"Fcons t ts == Abs_Forest(FCONS (Rep_Tree t) (Rep_Forest ts))"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    50
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    51
  TF_def	"TF(A) == lfp(%Z. A <*> Part Z In1 
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    52
                           <+> ({Numb(0)} <+> Part Z In0 <*> Part Z In1))"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    53
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    54
rules
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    55
  (*faking a type definition for tree...*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    56
  Rep_Tree 	   "Rep_Tree(n): Part (TF(range Leaf)) In0"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    57
  Rep_Tree_inverse "Abs_Tree(Rep_Tree(t)) = t"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    58
  Abs_Tree_inverse "z: Part (TF(range Leaf)) In0 ==> Rep_Tree(Abs_Tree(z)) = z"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    59
    (*faking a type definition for forest...*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    60
  Rep_Forest 	     "Rep_Forest(n): Part (TF(range Leaf)) In1"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    61
  Rep_Forest_inverse "Abs_Forest(Rep_Forest(ts)) = ts"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    62
  Abs_Forest_inverse 
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    63
	"z: Part (TF(range Leaf)) In1 ==> Rep_Forest(Abs_Forest(z)) = z"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    64
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    65
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    66
defs
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    67
     (*recursion*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    68
  TF_rec_def	
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    69
   "TF_rec M b c d == wfrec (trancl pred_sexp) M   
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    70
               (Case (Split(%x y g. b x y (g y))) 
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    71
	              (List_case (%g.c) (%x y g. d x y (g x) (g y))))"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    72
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    73
  tree_rec_def
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    74
   "tree_rec t b c d == 
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    75
   TF_rec (Rep_Tree t) (%x y r. b (Inv Leaf x) (Abs_Forest y) r) 
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    76
          c (%x y rt rf. d (Abs_Tree x) (Abs_Forest y) rt rf)"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    77
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    78
  forest_rec_def
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    79
   "forest_rec tf b c d == 
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    80
   TF_rec (Rep_Forest tf) (%x y r. b (Inv Leaf x) (Abs_Forest y) r) 
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    81
          c (%x y rt rf. d (Abs_Tree x) (Abs_Forest y) rt rf)"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    82
end