src/HOLCF/IOA/meta_theory/Seq.thy
author wenzelm
Mon, 22 May 2000 11:56:55 +0200
changeset 8907 813fabceec00
parent 5976 44290b71a85f
child 10835 f4745d77e620
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     1
(*  Title:      HOLCF/IOA/meta_theory/Seq.thy
3275
3f53f2c876f4 changes for release 94-8
mueller
parents: 3071
diff changeset
     2
    ID:         $Id$
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     3
    Author:     Olaf M"uller
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     4
    Copyright   1996  TU Muenchen
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     5
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     6
Partial, Finite and Infinite Sequences (lazy lists), modeled as domain.
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     7
*)  
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     8
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     9
5102
8c782c25a11e Adapted to new inductive definition package.
berghofe
parents: 4283
diff changeset
    10
Seq = HOLCF + Inductive +
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    11
4122
f63c283cefaf * removed "axioms" and "generated by" section
oheimb
parents: 3847
diff changeset
    12
domain 'a seq = nil | "##" (HD::'a) (lazy TL::'a seq)  (infixr 65) 
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    13
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    14
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    15
consts    
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    16
   sfilter       :: "('a -> tr) -> 'a seq -> 'a seq"  
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    17
   smap          :: "('a -> 'b) -> 'a seq -> 'b seq"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    18
   sforall       :: "('a -> tr) => 'a seq => bool"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    19
   sforall2      :: "('a -> tr) -> 'a seq -> tr"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    20
   slast         :: "'a seq     -> 'a"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    21
   sconc         :: "'a seq     -> 'a seq -> 'a seq"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    22
   sdropwhile,
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    23
   stakewhile    ::"('a -> tr)  -> 'a seq -> 'a seq"  
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    24
   szip          ::"'a seq      -> 'b seq -> ('a*'b) seq"  
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    25
   sflat        :: "('a seq) seq  -> 'a seq"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    26
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    27
   sfinite       :: "'a seq set"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    28
   Partial       ::"'a seq => bool"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    29
   Infinite      ::"'a seq => bool"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    30
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    31
   nproj        :: "nat => 'a seq => 'a"
4282
d30fbe129683 resolved merge conflict;
mueller
parents: 4122
diff changeset
    32
   sproj        :: "nat => 'a seq => 'a seq"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    33
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    34
syntax
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    35
   "@@"		:: "'a seq => 'a seq => 'a seq"	(infixr 65)
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    36
   "Finite"     :: "'a seq => bool"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    37
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    38
translations
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    39
   "xs @@ ys" == "sconc`xs`ys"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    40
   "Finite x" == "x:sfinite"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    41
   "~(Finite x)" =="x~:sfinite"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    42
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    43
defs 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    44
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    45
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    46
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    47
(* f not possible at lhs, as "pattern matching" only for % x arguments,
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    48
   f cannot be written at rhs in front, as fix_eq3 does not apply later *)
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    49
smap_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    50
  "smap == (fix`(LAM h f tr. case tr of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    51
      nil   => nil
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    52
    | x##xs => f`x ## h`f`xs))"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    53
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    54
sfilter_def       
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    55
  "sfilter == (fix`(LAM h P t. case t of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    56
	   nil => nil
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    57
	 | x##xs => If P`x                                 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    58
                    then x##(h`P`xs)
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    59
                    else     h`P`xs
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    60
                    fi))" 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    61
sforall_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    62
  "sforall P t == (sforall2`P`t ~=FF)" 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    63
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    64
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    65
sforall2_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    66
  "sforall2 == (fix`(LAM h P t. case t of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    67
	   nil => TT
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    68
	 | x##xs => P`x andalso h`P`xs))"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    69
  
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    70
sconc_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    71
  "sconc == (fix`(LAM h t1 t2. case t1 of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    72
               nil       => t2
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    73
             | x##xs => x##(h`xs`t2)))"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    74
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    75
slast_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    76
  "slast == (fix`(LAM h t. case t of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    77
	   nil => UU
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    78
	 | x##xs => (If is_nil`xs                              
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    79
                          then x
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    80
                         else h`xs fi)))"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    81
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    82
stakewhile_def      
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    83
  "stakewhile == (fix`(LAM h P t. case t of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    84
	   nil => nil
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    85
	 | x##xs => If P`x                                 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    86
                    then x##(h`P`xs)
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    87
                    else nil
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    88
                    fi))" 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    89
sdropwhile_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    90
  "sdropwhile == (fix`(LAM h P t. case t of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    91
	   nil => nil
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    92
	 | x##xs => If P`x                                 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    93
                    then h`P`xs
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    94
                    else t
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    95
                    fi))" 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    96
sflat_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    97
  "sflat == (fix`(LAM h t. case t of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    98
	   nil => nil
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    99
	 | x##xs => x @@ (h`xs)))"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   100
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   101
szip_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   102
  "szip == (fix`(LAM h t1 t2. case t1 of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   103
               nil   => nil
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   104
             | x##xs => (case t2 of 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   105
                          nil => UU 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   106
                        | y##ys => <x,y>##(h`xs`ys))))"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   107
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   108
Partial_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   109
  "Partial x  == (seq_finite x) & ~(Finite x)"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   110
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   111
Infinite_def
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   112
  "Infinite x == ~(seq_finite x)"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   113
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   114
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   115
inductive "sfinite" 
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   116
   intrs  
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   117
    sfinite_0  "nil:sfinite"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   118
    sfinite_n  "[|tr:sfinite;a~=UU|] ==> (a##tr) : sfinite"
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   119
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   120
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
   121
end