Changeset 11877
- Timestamp:
- 03.07.2009 18:38:45 (5 months ago)
- Location:
- trunk/HasCASL
- Files:
-
- 12 modified
-
ParseItem.hs (modified) (1 diff)
-
test/Alias.hascasl (modified) (1 diff)
-
test/Alias.hascasl.output (modified) (2 diffs)
-
test/ContraVariance.hascasl (modified) (1 diff)
-
test/ContraVariance.hascasl.output (modified) (2 diffs)
-
test/Graphs.hascasl (modified) (2 diffs)
-
test/Graphs.hascasl.output (modified) (1 diff)
-
test/Items.hascasl (modified) (1 diff)
-
test/Items.hascasl.output (modified) (1 diff)
-
test/Prelude.hascasl (modified) (15 diffs)
-
test/WrongItems.hascasl (modified) (1 diff)
-
test/WrongItems.hascasl.output (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/HasCASL/ParseItem.hs
r11328 r11877 127 127 <|> typeItemList [p] Plain 128 128 129 -- | several 'typeArg's130 typeArgs :: AParser st ([TypeArg], [Token])131 typeArgs = do132 l <- many1 typeArg133 return (map fst l, concatMap snd l)134 135 pseudoType :: AParser st TypeScheme136 pseudoType = do137 l <- asKey lamS138 (ts, pps) <- typeArgs139 d <- dotT140 t <- pseudoType141 let qs = toRange l pps d142 case t of143 TypeScheme ts1 gt ps ->144 return $ TypeScheme (ts ++ ts1) gt $ appRange qs ps145 <|> do146 st <- parseType147 return $ simpleTypeScheme st148 149 129 pseudoTypeDef :: TypePattern -> Maybe Kind -> [Token] -> AParser st TypeItem 150 130 pseudoTypeDef t k l = do 151 131 c <- asKey assignS 152 p <- p seudoType153 return $ AliasType t k p$ catRange $ l ++ [c]132 p <- parseType 133 return $ AliasType t k (simpleTypeScheme p) $ catRange $ l ++ [c] 154 134 155 135 -- * parsing datatypes -
trunk/HasCASL/test/Alias.hascasl
r8578 r11877 6 6 7 7 type a1 a b := a -> b -> Unit 8 type a1 := \ (a) (b) .a -> b -> Unit 9 type a1 a := \ b .a -> b -> Unit 8 type a1 (a) (b) := a -> b -> Unit 10 9 11 type a2 := \ (a) (b) .a -> Unit10 type a2 a b := a -> Unit 12 11 13 type a3 := \ (a) (a) .a -> Unit12 type a3 (a) (a) := a -> Unit 14 13 15 14 type a4 a a := a -> Unit -
trunk/HasCASL/test/Alias.hascasl.output
r10502 r11877 4 4 type MyPred s := s ->? Unit 5 5 type MyAlias t := t ->? Unit 6 type a1 a b := a -> b -> Unit7 6 type a1 a b := a -> b -> Unit 8 7 type a1 a b := a -> b -> Unit … … 49 48 *** Error 7.9, unknown type variable 'a' 50 49 *** Error 7.11, unknown type variable 'b' 51 *** Error 8.1 5, unknown type variable 'a'52 *** Error 8.1 9, unknown type variable 'b'50 *** Error 8.10, unknown type variable 'a' 51 *** Error 8.14, unknown type variable 'b' 53 52 ### Hint 8.6, redeclared type 'a1' 54 *** Error 9.9, unknown type variable 'a' 55 *** Error 9.16, unknown type variable 'b' 56 ### Hint 9.6, redeclared type 'a1' 57 *** Error 11.15, unknown type variable 'a' 58 *** Error 11.19, unknown type variable 'b' 59 *** Error 13.15, unknown type variable 'a' 60 *** Error 13.15, duplicates at '(13,19)' for 'a' 61 *** Error 15.9, unknown type variable 'a' 62 *** Error 15.9, duplicates at '(15,11)' for 'a' 63 *** Error 17.9, unknown type variable 'a' 64 *** Error 19.9, unknown type variable 'a' 65 *** Error 19.14-19.22, 53 *** Error 10.9, unknown type variable 'a' 54 *** Error 10.11, unknown type variable 'b' 55 *** Error 12.10, unknown type variable 'a' 56 *** Error 12.10, duplicates at '(12,14)' for 'a' 57 *** Error 14.9, unknown type variable 'a' 58 *** Error 14.9, duplicates at '(14,11)' for 'a' 59 *** Error 16.9, unknown type variable 'a' 60 *** Error 18.9, unknown type variable 'a' 61 *** Error 18.14-18.22, 66 62 illegal recursive type synonym 'a5 a -> Unit' 67 *** Error 2 1.9, unknown type variable 'a'68 *** Error 2 3.9, unknown type variable 'a'69 *** Error 2 5.9, unknown type variable 'a'70 *** Error 2 3.9-25.22, illegal recursive type synonym 'a7 a -> Unit'71 *** Error 2 7.6,63 *** Error 20.9, unknown type variable 'a' 64 *** Error 22.9, unknown type variable 'a' 65 *** Error 24.9, unknown type variable 'a' 66 *** Error 22.9-24.22, illegal recursive type synonym 'a7 a -> Unit' 67 *** Error 26.6, 72 68 incompatible kind of: a2 73 69 expected: Type -> Type -> Type -
trunk/HasCASL/test/ContraVariance.hascasl
r8098 r11877 1 type p := \ (a : +Type) . Pred (Pred a) %% should be correct 2 type p := \ (a : +Type) . Pred a %% should be wrong 3 type m := \ (b : -Type) . b %% 4 type m := \ (b : +Type) . b %% both contradict 1 var a : +Type 2 type p a := Pred (Pred a) %% should be correct 3 type p a := Pred a %% should be wrong 4 type m (b : -Type) := b %% 5 type m (b : +Type) := b %% both contradict -
trunk/HasCASL/test/ContraVariance.hascasl.output
r9230 r11877 1 var a : +Type 1 2 type p a := Pred (Pred a) 2 3 %% should be correct … … 9 10 m := \ b : -Type . b; 10 11 p := \ a : +Type . Pred (Pred a) 11 ### Hint 2.32, wrong covariance of 'a' 12 ### Hint 2.32, no kind found for 'a' 13 *** Error 2.27-2.32, no kind found for 'Pred a' 14 *** Error 4.6, 12 var 13 a : +Type %(var_1)% 14 ### Hint 1.5, is type variable 'a' 15 ### Hint 3.18, wrong covariance of 'a' 16 ### Hint 3.18, no kind found for 'a' 17 *** Error 3.13-3.18, no kind found for 'Pred a' 18 *** Error 5.6, 15 19 wrong type of 'm' 16 20 expected: \ b : -Type . b -
trunk/HasCASL/test/Graphs.hascasl
r4967 r11877 1 1 var S,T : Type 2 2 type Bool; 3 Pred := \ (S: -Type) .S ->? Unit ;4 Set := \ S:Type .S ->? Unit ;3 Pred (S: -Type) := S ->? Unit ; 4 Set (S:Type) := S ->? Unit ; 5 5 ops True, False : Bool; 6 6 … … 14 14 __disjointUnion__ : Set S * Set S -> Set (S*Bool); 15 15 inl,inr : S -> S*Bool; 16 forall x,x':S; y:T; s,s':Set(S); t:Set(T) 16 forall x,x':S; y:T; s,s':Set(S); t:Set(T) 17 17 . not (x isIn emptySet) 18 18 . (x isIn {x'}) <=> x=x' -
trunk/HasCASL/test/Graphs.hascasl.output
r10502 r11877 70 70 ### Hint 1.6, is type variable 'S' 71 71 ### Hint 1.8, is type variable 'T' 72 ### Hint 3.1 9, rebound type variable 'S'72 ### Hint 3.14, rebound type variable 'S' 73 73 ### Hint 3.8, redeclared type 'Pred' 74 ### Hint 4.1 7, rebound type variable 'S'74 ### Hint 4.13, rebound type variable 'S' 75 75 ### Hint 9.18, 76 76 no kind found for 'S' -
trunk/HasCASL/test/Items.hascasl
r10650 r11877 3 3 var {a}: c -> d 4 4 class Monad < Type -> Type 5 type a : Monad := \ t .t -> t5 type (a : Monad) t := t -> t 6 6 free type Term ::= Var Variable | Lam Variable Term | App Term Term 7 7 type WNet={(sys,i,o): T * T * T . i = o } -
trunk/HasCASL/test/Items.hascasl.output
r7441 r11877 3 3 var {a} : c -> d 4 4 class Monad < Type -> Type 5 type at := t -> t5 type (a : Monad) t := t -> t 6 6 free type Term ::= Var Variable | Lam Variable Term | App Term Term 7 7 type WNet = {(sys, i, o) : T * T * T . i = o} -
trunk/HasCASL/test/Prelude.hascasl
r4544 r11877 1 %% predefined universe containing all types, 1 %% predefined universe containing all types, 2 2 %% superclass of all other classes 3 3 4 4 class Type 5 5 6 var s,t : Type 6 var s,t : Type 7 7 8 8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 12 12 13 13 %% type aliases 14 type Pred __ : Type -> Type := \ t: -Type . t ->? Unit15 type ? __ := \ t:Type .Unit ->? t14 type Pred __ (t: -Type) := t ->? Unit 15 type ? __ (t:Type) := Unit ->? t 16 16 17 17 pred true, false : Unit … … 34 34 35 35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36 %% "pred p args = e" abbreviates "op p args :? unit = e" 36 %% "pred p args = e" abbreviates "op p args :? unit = e" 37 37 %% CASL requires "<=>" for pred-defn and disallows "()" as result 38 38 … … 40 40 var x : s 41 41 42 program def = \x: s . () %% def is also total (identical to tt) 42 program def = \x: s . () %% def is also total (identical to tt) 43 43 44 44 program tt = \x: s . () %% tt is total "op tt(x: s): unit = ()" … … 48 48 49 49 %% total function type 50 type __->__ : -Type -> +Type -> Type 50 type __->__ : -Type -> +Type -> Type 51 51 52 52 type __->__ < __ ->? __ … … 56 56 57 57 %% 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 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 61 61 62 62 63 63 %% trivial because its the strict function property 64 64 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)) 66 66 . fst = (__ res__) 67 67 … … 77 77 %% then %def 78 78 79 %% notation "\ ." abbreviates "\bla:unit." 79 %% notation "\ ." abbreviates "\bla:unit." 80 80 %% where "bla" is never used, but only "()" instead 81 81 82 %% for type inference 82 %% for type inference 83 83 %% an implicit cast from s to ?s of a term "e" yields the term "\ . e" 84 84 … … 93 93 program __impl__ (x, y: Pred Unit) : Pred Unit = eq(x, x And y) 94 94 95 program __or__ (x, y: Pred Unit) : Pred Unit = all(\r: Pred Unit. 95 program __or__ (x, y: Pred Unit) : Pred Unit = all(\r: Pred Unit. 96 96 ((x impl r) und (y impl r)) impl r) 97 97 … … 103 103 program neg (r: Pred Unit) : Pred Unit = r impl ff 104 104 105 %% the type instance for the first "eq" should be "?t" 105 %% the type instance for the first "eq" should be "?t" 106 106 %% this is explicitely enforced by "\ .f(x)" 107 107 … … 109 109 110 110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 111 %% Recursion (requires "free type nat ::= 0 | Suc(nat)" and "+" 111 %% Recursion (requires "free type nat ::= 0 | Suc(nat)" and "+" 112 112 113 113 type nat … … 124 124 125 125 pred 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) 126 pred isBound (x: c; s: nat -> c) <=> all(\n:nat. s(n) <<= x) 127 127 128 128 op sup : (nat -> c) ->? c … … 139 139 var p : Pcpo 140 140 141 op bottom : p 142 143 . all(\x : p. bottom <<= x) 141 op bottom : p 142 143 . all(\x : p. bottom <<= x) 144 144 } 145 145 146 146 class instance Flatcpo < Cpo 147 147 { 148 var f : Flatcpo 148 var f : Flatcpo 149 149 150 150 program __<<=[f]__ = eq … … 155 155 type instance __*__ : +Cpo -> +Cpo -> Cpo 156 156 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 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 163 163 164 164 type Unit : Pcpo 165 165 166 166 %% Pcont 167 type instance __-->?__ : -Cpo -> +Cpo -> Pcpo 167 type instance __-->?__ : -Cpo -> +Cpo -> Pcpo 168 168 169 169 type __-->?__ < __->?__ 170 . __ in c -->? d = \f : c ->? d . 170 . __ in c -->? d = \f : c ->? d . 171 171 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 174 174 eq(sup(\n:nat.!f(s(n+m))), f(sup(s))))) 175 175 … … 179 179 type instance __-->__ : -Cpo -> +Cpo -> Cpo 180 180 181 type __-->__ < __-->?__ 181 type __-->__ < __-->?__ 182 182 . __ in c --> d = \f : c -->? d . all(\x:c. def f(x)) 183 183 184 184 var f, g : c --> d 185 185 186 program f <<= g = f <<=[c -->? d] g 186 program f <<= g = f <<=[c -->? d] g 187 187 188 188 type instance __-->__ : -Cpo -> +Pcpo -> Pcpo … … 195 195 var f : p --> p; x : p 196 196 . f(Y(f)) = Y(f) 197 . f(x) = x => Y(f) <<= x 197 . f(x) = x => Y(f) <<= x 198 198 199 199 op undefined : c --> p = Y((\x': c --> p . x') as (c --> p) --> c --> p) -
trunk/HasCASL/test/WrongItems.hascasl
r10262 r11877 2 2 var < 3 3 class a < Type = {x . x < t} 4 type t := \ s,r .s -> r4 type t (s,r) := s -> r 5 5 type n (r,s) -
trunk/HasCASL/test/WrongItems.hascasl.output
r10262 r11877 11 11 expecting "[", "%", "->", "{", ";", "sort", "op", "fun", "pred", "type", class, "program", "generated", "free", "var", "forall", dot, "axiom", "internal" or end of input 12 12 13 parse error at 4.1 7:13 parse error at 4.12: 14 14 unexpected list of type arguments 15 expecting "%", "+", "-", ",", ":" or "<"15 expecting casl char, "_", "%", "+", "-", ",", ":" or "<" 16 16 17 17 parse error at 5.12: