Show
Ignore:
Timestamp:
03.07.2009 18:38:45 (5 months ago)
Author:
maeder
Message:

disallowed explicit pseudo type notation following := (assign)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/HasCASL/test/Prelude.hascasl

    r4544 r11877  
    1 %% predefined universe containing all types,  
     1%% predefined universe containing all types, 
    22%% superclass of all other classes 
    33 
    44class Type 
    55 
    6 var s,t  : Type  
     6var s,t  : Type 
    77 
    88%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     
    1212 
    1313%% type aliases 
    14 type Pred __ : Type -> Type := \ t: -Type . t ->? Unit  
    15 type ? __ := \ t:Type . Unit ->? t 
     14type Pred __ (t: -Type) := t ->? Unit 
     15type ? __ (t:Type) := Unit ->? t 
    1616 
    1717pred true, false : Unit 
     
    3434 
    3535%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    36 %% "pred p args = e" abbreviates "op p args :? unit = e"   
     36%% "pred p args = e" abbreviates "op p args :? unit = e" 
    3737%% CASL requires "<=>" for pred-defn and disallows "()" as result 
    3838 
     
    4040var x : s 
    4141 
    42 program def = \x: s . () %% def is also total (identical to tt)  
     42program def = \x: s . () %% def is also total (identical to tt) 
    4343 
    4444program tt = \x: s . ()  %% tt is total "op tt(x: s): unit = ()" 
     
    4848 
    4949%% total function type 
    50 type __->__ : -Type -> +Type -> Type  
     50type __->__ : -Type -> +Type -> Type 
    5151 
    5252type __->__ < __ ->? __ 
     
    5656 
    5757%% total functions 
    58 op __res__ (x: s; y: t) : s = x  
    59 op fst (x: s; y: t) : s = x  
    60 program snd (x: s, y: t) : t = y  
     58op __res__ (x: s; y: t) : s = x 
     59op fst (x: s; y: t) : s = x 
     60program snd (x: s, y: t) : t = y 
    6161 
    6262 
    6363%% trivial because its the strict function property 
    6464 
    65 . (\ (x:s, y:t). def (x res y)) =  (\ (x:s, y:t). (def y) und (def x))  
     65. (\ (x:s, y:t). def (x res y)) =  (\ (x:s, y:t). (def y) und (def x)) 
    6666. fst = (__ res__) 
    6767 
     
    7777%% then %def 
    7878 
    79 %% notation "\ ."  abbreviates "\bla:unit."  
     79%% notation "\ ."  abbreviates "\bla:unit." 
    8080%% where "bla" is never used, but only "()" instead 
    8181 
    82 %% for type inference  
     82%% for type inference 
    8383%% an implicit cast from s to ?s of a term "e" yields the term "\ . e" 
    8484 
     
    9393program __impl__ (x, y: Pred Unit) : Pred Unit = eq(x, x And y) 
    9494 
    95 program __or__ (x, y: Pred Unit) : Pred Unit = all(\r: Pred Unit.  
     95program __or__ (x, y: Pred Unit) : Pred Unit = all(\r: Pred Unit. 
    9696                ((x impl r) und (y impl r)) impl r) 
    9797 
     
    103103program neg (r: Pred Unit) : Pred Unit = r impl ff 
    104104 
    105 %% the type instance for the first "eq" should be "?t"  
     105%% the type instance for the first "eq" should be "?t" 
    106106%% this is explicitely enforced by "\ .f(x)" 
    107107 
     
    109109 
    110110%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    111 %% Recursion (requires "free type nat ::= 0 | Suc(nat)" and "+"   
     111%% Recursion (requires "free type nat ::= 0 | Suc(nat)" and "+" 
    112112 
    113113type nat 
     
    124124 
    125125pred isChain (s: nat -> c) <=> all(\n:nat. s(n) <<= s(Suc(n))) 
    126 pred isBound (x: c; s: nat -> c) <=> all(\n:nat. s(n) <<= x)   
     126pred isBound (x: c; s: nat -> c) <=> all(\n:nat. s(n) <<= x) 
    127127 
    128128op sup : (nat -> c) ->? c 
     
    139139var p : Pcpo 
    140140 
    141 op bottom : p  
    142  
    143 . all(\x : p. bottom <<= x)    
     141op bottom : p 
     142 
     143. all(\x : p. bottom <<= x) 
    144144} 
    145145 
    146146class instance Flatcpo < Cpo 
    147147{ 
    148  var f : Flatcpo  
     148 var f : Flatcpo 
    149149 
    150150 program __<<=[f]__ = eq 
     
    155155type instance __*__ : +Cpo -> +Cpo -> Cpo 
    156156 
    157 var x1,x2 : c; y1, y2 : d  
    158  
    159 program (x1, y1) <<= (x2, y2) = (x1 <<= x2) und (y1 <<= y2)  
    160  
    161  
    162 type instance __*__ : +Pcpo -> +Pcpo -> Pcpo       
     157var x1,x2 : c; y1, y2 : d 
     158 
     159program (x1, y1) <<= (x2, y2) = (x1 <<= x2) und (y1 <<= y2) 
     160 
     161 
     162type instance __*__ : +Pcpo -> +Pcpo -> Pcpo 
    163163 
    164164type Unit : Pcpo 
    165165 
    166166%% Pcont 
    167 type instance __-->?__ : -Cpo -> +Cpo -> Pcpo  
     167type instance __-->?__ : -Cpo -> +Cpo -> Pcpo 
    168168 
    169169 type __-->?__ < __->?__ 
    170  . __ in c -->? d  = \f : c ->? d .  
     170 . __ in c -->? d  = \f : c ->? d . 
    171171        all(\(x,y: c). (def (f x) und x <<= y) impl def (f y)) und 
    172         all(\s: nat -> c. (isChain(s) und def f(sup(s))) impl  
    173                 ex(\m:nat. def f(s(m)) und  
     172        all(\s: nat -> c. (isChain(s) und def f(sup(s))) impl 
     173                ex(\m:nat. def f(s(m)) und 
    174174                        eq(sup(\n:nat.!f(s(n+m))), f(sup(s))))) 
    175175 
     
    179179type instance __-->__ : -Cpo -> +Cpo -> Cpo 
    180180 
    181  type __-->__ < __-->?__  
     181 type __-->__ < __-->?__ 
    182182 . __ in c --> d = \f : c -->? d . all(\x:c. def f(x)) 
    183183 
    184184 var f, g : c --> d 
    185185 
    186  program f <<= g = f <<=[c -->? d] g  
     186 program f <<= g = f <<=[c -->? d] g 
    187187 
    188188type instance __-->__ : -Cpo -> +Pcpo -> Pcpo 
     
    195195var f : p --> p; x : p 
    196196. f(Y(f)) = Y(f) 
    197 . f(x) = x => Y(f) <<= x   
     197. f(x) = x => Y(f) <<= x 
    198198 
    199199op undefined : c --> p = Y((\x': c --> p . x') as (c --> p) --> c --> p)