Changeset 11873

Show
Ignore:
Timestamp:
03.07.2009 16:16:41 (9 months ago)
Author:
maeder
Message:

fully close type environment of formulas (considering down sets)

Location:
trunk/HasCASL
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/HasCASL/VarDecl.hs

    r11328 r11873  
    2323import qualified Data.Set as Set 
    2424import Common.Id 
     25import Common.Lib.Rel (setToMap) 
    2526import Common.Lib.State 
    2627import Common.Result 
     
    4546mkEnvForall :: Env -> Term -> Range -> Term 
    4647mkEnvForall e t ps = 
    47   let tys = Set.fromList $ map (fst . snd) $ concatMap (leaves (>= 0)) 
    48             $ getAllTypes t 
    49       tyVs = map ( \ (i, TypeVarDefn v vk rk c) -> GenTypeVarDecl $ 
    50                    TypeArg i v vk rk c Other ps) $ Map.toList 
    51              $ Map.filterWithKey ( \ i _ -> Set.member i tys) $ localTypeVars e 
     48  let tys = getAllTypes t 
     49      tyVs = map GenTypeVarDecl $ getTypeVars (localTypeVars e) tys ps 
    5250      vs = tyVs ++ map GenVarDecl (Set.toList $ freeVars t) 
    5351  in if null vs then t else QuantifiedTerm Universal vs t ps 
     52 
     53getTypeVars :: LocalTypeVars -> [Type] -> Range -> [TypeArg] 
     54getTypeVars e tys ps = 
     55  let is = Set.unions $ map (idsOf (>= 0)) tys 
     56      tyVs = Map.intersection e $ setToMap is 
     57      dTys = Map.fold (\ (TypeVarDefn _ vk _ _) l -> case vk of 
     58             Downset ty -> ty : l 
     59             _ -> l) [] tyVs 
     60      dis = Set.unions $ map (idsOf (>= 0)) dTys 
     61  in if Set.isSubsetOf dis is then 
     62          map ( \ (i, TypeVarDefn v vk rk c) -> TypeArg i v vk rk c Other ps) 
     63          $ Map.toList tyVs 
     64     else getTypeVars e (dTys ++ tys) ps 
    5465 
    5566anaStarType :: Type -> State Env (Maybe Type) 
  • trunk/HasCASL/test/Subtype.hascasl.output

    r11869 r11873  
    5959forall a < b : Type; b < c : Type; c : Type; x : a 
    6060. up (up x : b) = (up x : c) 
    61 forall a < b : Type; b < c : Type; x : a . up x = (x : b) 
     61forall a < b : Type; b < c : Type; c : Type; x : a . up x = (x : b) 
    6262forall e : Type; f : Type; f : e -> f 
    6363. (up f : e ->? f) = \ x : e . f x