Sublogic.hs revision 3daa82a175c7cfabf22455aa77c4beda327404e4
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannModule : $Header$
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannDescription : HasCASL's sublogics
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannCopyright : (c) Sonja Groening, C. Maeder, and Uni Bremen 2002-2006
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannMaintainer : Christian.Maeder@dfki.de
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannStability : experimental
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannPortability : portable
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannThis module provides the sublogic functions (as required by Logic.hs) for
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann HasCASL. The functions allow to compute the minimal sublogic needed by a
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann given element, to check whether an item is part of a given sublogic, and --
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann not yet -- to project an element into a given sublogic.
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann ( -- * datatypes
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , Formulas(..)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , Classes(..)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -- * functions for SemiLatticeWithTop instance
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , sublogic_max
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -- * combining sublogics restrictions
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , sublogic_min
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -- * further sublogic constants
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -- * functions for Logic instance
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -- ** sublogic to string converstion
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , sublogic_name
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -- ** list of all sublogics
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , sublogics_all
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -- ** checks if element is in given sublogic
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , in_basicSpec
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , in_sentence
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , in_symbItems
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , in_symbMapItems
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , in_morphism
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann -- * computes the sublogic of a given element
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , sl_basicSpec
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , sl_sentence
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , sl_symbItems
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , sl_symbMapItems
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , sl_morphism
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Data.Map as Map
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmannimport qualified Data.Set as Set
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann-- | formula kinds of HasCASL sublogics
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann = Atomic -- ^ atomic logic
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann | Horn -- ^ positive conditional logic
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann | GHorn -- ^ generalized positive conditional logic
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann | FOL -- ^ first-order logic
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann | HOL -- ^ higher-order logic
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann deriving (Show, Eq, Ord)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmanndata Classes = NoClasses | SimpleTypeClasses | ConstructorClasses
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann deriving (Show, Eq, Ord)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann-- | HasCASL sublogics
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmanndata Sublogic = Sublogic
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann { has_sub :: Bool -- ^ subsorting
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_part :: Bool -- ^ partiality
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_eq :: Bool -- ^ equality
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_pred :: Bool -- ^ predicates
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , type_classes :: Classes
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_polymorphism :: Bool
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_type_constructors :: Bool
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , which_logic :: Formulas
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann } deriving (Show, Eq, Ord)
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann-- * special sublogic elements
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann-- | top element
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmanntopLogic :: Sublogic
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmanntopLogic = Sublogic
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann { has_sub = True
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_part = True
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_eq = True
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_pred = True
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , type_classes = ConstructorClasses
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_polymorphism = True
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , has_type_constructors = True
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann , which_logic = HOL
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann-- | top sublogic without subtypes
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannnoSubtypes :: Sublogic
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannnoSubtypes = topLogic { has_sub = False }
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann-- | top sublogic without type classes
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannnoClasses :: Sublogic
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmannnoClasses = topLogic { type_classes = NoClasses }
2450a4210dee64b064499a3a1154129bdfc74981Daniel Hausmann-- | top sublogic without partiality
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmanntotalFuns :: Sublogic
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmanntotalFuns = topLogic { has_part = False }
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmanncaslLogic :: Sublogic
2450a4210dee64b064499a3a1154129bdfc74981Daniel HausmanncaslLogic = noClasses
sublogic via sublogic_max, i.e. (sublogic_max given needs_part)
-- | make sublogic consistent w.r.t. illegal combinations
They are adapted for HasCASL, especially HasCASLs abstract syntax (As.hs)
no lambda/let/case,
no higher types (i.e. all types are basic, tuples, or tuple -> basic)
(if Map.null $ classMap e then bottom else simpleTypeClasses)
: map sl_typeInfo (Map.elems $ typeMap e)
++ map sl_opInfos (Map.elems $ assumps e)
sublogic_max (if Set.null $ superTypes t then bottom else need_sub)
comp_list $ map sl_typeArg l ++ map sl_altDefn (Set.toList m)
sl_opInfos :: Set.Set OpInfo -> Sublogic
sl_opInfos = comp_list . map sl_opInfo . Set.toList
: map sl_opAttr (Set.toList $ opAttrs o)
SelectData l _ -> comp_list $ map sl_constrInfo $ Set.toList l