src/HOL/ex/Term.thy
author berghofe
Tue, 25 Jun 1996 13:11:29 +0200
changeset 1824 44254696843a
parent 1476 608483c2122a
child 2911 8a680e310f04
permissions -rw-r--r--
Changed argument order of nat_rec.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
     1
(*  Title:      HOL/ex/Term
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1992  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
Terms over a given alphabet -- function applications; illustrates list functor
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     7
  (essentially the same type as in Trees & Forests)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     8
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     9
There is no constructor APP because it is simply cons ($) 
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    10
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    11
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    12
Term = SList +
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    13
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    14
types   'a term
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    15
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    16
arities term :: (term)term
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    17
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    18
consts
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    19
  term          :: 'a item set => 'a item set
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    20
  Rep_term      :: 'a term => 'a item
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    21
  Abs_term      :: 'a item => 'a term
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    22
  Rep_Tlist     :: 'a term list => 'a item
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    23
  Abs_Tlist     :: 'a item => 'a term list
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    24
  App           :: ['a, ('a term)list] => 'a term
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    25
  Term_rec      :: ['a item, ['a item , 'a item, 'b list]=>'b] => 'b
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    26
  term_rec      :: ['a term, ['a ,'a term list, 'b list]=>'b] => 'b
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    27
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    28
inductive "term(A)"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    29
  intrs
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    30
    APP_I "[| M: A;  N : list(term(A)) |] ==> M$N : term(A)"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    31
  monos   "[list_mono]"
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    32
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    33
defs
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    34
  (*defining abstraction/representation functions for term list...*)
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    35
  Rep_Tlist_def "Rep_Tlist == Rep_map(Rep_term)"
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    36
  Abs_Tlist_def "Abs_Tlist == Abs_map(Abs_term)"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    37
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    38
  (*defining the abstract constants*)
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    39
  App_def       "App a ts == Abs_term(Leaf(a) $ Rep_Tlist(ts))"
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
  (*list recursion*)
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    42
  Term_rec_def  
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    43
   "Term_rec M d == wfrec (trancl pred_sexp)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    44
           (%g. Split(%x y. d x y (Abs_map g y))) M"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    45
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    46
  term_rec_def
1151
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    47
   "term_rec t d == 
c820b3cc3df0 removed \...\ inside strings
clasohm
parents: 969
diff changeset
    48
   Term_rec (Rep_term t) (%x y r. d (Inv Leaf x) (Abs_Tlist(y)) r)"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    49
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    50
rules
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    51
    (*faking a type definition for term...*)
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    52
  Rep_term              "Rep_term(n): term(range(Leaf))"
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    53
  Rep_term_inverse      "Abs_term(Rep_term(t)) = t"
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1376
diff changeset
    54
  Abs_term_inverse      "M: term(range(Leaf)) ==> Rep_term(Abs_term(M)) = M"
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    55
end