Changeset 12749

Show
Ignore:
Timestamp:
29.10.2009 16:26:02 (3 weeks ago)
Author:
kristina
Message:

Added headers and algorithm descriptions

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/Comorphisms/DFOL2CASL.hs

    r11854 r12749  
     1{- | 
     2Module      :  $Header$ 
     3Description :  Translation of first-order logic with dependent types (DFOL) to 
     4               CASL 
     5Copyright   :  (c) Kristina Sojakova, DFKI Bremen 2009 
     6License     :  similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt 
     7 
     8Maintainer  :  k.sojakova@jacobs-university.de 
     9Stability   :  experimental 
     10Portability :  portable 
     11 
     12Ref: K. Sojakova and F. Rabe. Translating a Dependently-Typed Logic to 
     13     First-Order Logic. LNCS 2009, pages 326-341. 
     14-} 
     15 
    116module Comorphisms.DFOL2CASL where 
    217 
  • trunk/DFOL/AS_DFOL.hs

    r12746 r12749  
    3939      translate, 
    4040      getNewName, 
    41       getFreeVars   
     41      getFreeVars 
    4242   )  where 
    4343 
  • trunk/DFOL/Colimit.hs

    r12716 r12749  
    99Stability   :  experimental 
    1010Portability :  portable 
     11 
     12Algorithm description: 
     13 
     14Input : graph where nodes are signatures and edges are morphisms 
     15Output : a signature "sig" and for each input signature "sig1" a morphism 
     16         m : sig1 -> sig 
     17 
     181 : Compute the transitive and symmetric closure of the relation R induced 
     19    by the morphisms in the graph 
     20 
     212 : Initialize the output signature "sig" and collection of morphisms "M" to 
     22    empty 
     23    Initialize the set of analyzed symbols to empty 
     24 
     253 : For each input signature sig1 : 
     26    3.1 : Initialize the output map "m" to empty 
     27    3.2 : For each symbol "s" in sig1 (keeping the order in which they are 
     28              defined) : 
     29          3.1.1 Check if s R s' for any already analyzed symbol "s'" 
     30          3.1.2 If yes: 
     31                3.1.2.1 Recover from M the value "c" that s' maps to 
     32                                3.1.2.2 Update m by adding the pair (s,c) 
     33                  3.1.3 If no: 
     34                3.1.3.1 Get the type "t" of s in sig1 
     35                3.1.3.2 Translate t along m; call this new type "t1" 
     36                3.1.3.3 Update sig by adding the declaration s : t1 
     37                        (in case the name s is already contained in sig, 
     38                                                we generate a fresh name "s1" and add the declaration 
     39                        s1 : t and pair (s,s1) to sig and m respectively. 
     40    3.3 : Add m to M 
    1141-} 
    1242 
  • trunk/DFOL/Morphism.hs

    r12746 r12749  
    9797 
    9898-- generated and cogenerated signatures 
     99{- Algorithm description: 
     100 
     101FOR GENERATED SIGNATURES 
     102 
     103Input : a signature "sig" and a set of symbols "syms" 
     104Output : an inclusion morphism 
     105 
     1061 : Check if all symbols in syms occur in sig; if not, output Nothing 
     107 
     1082 : Initialize the set of symbols "incl" which necessarily must be included 
     109    in the generated signature to syms 
     110    Initialize the set "done" of analyzed symbols to empty 
     111    Initialize the set "todo" of symbols to be analyzed to syms 
     112 
     1133 : Check if todo is empty 
     114    3.1 : If yes, go to 5 
     115        3.2 : If not, go to 4 
     116 
     1174 : Pick a symbol "s" from todo 
     118    4.1 : Get the type "t" of s in sig 
     119        4.2 : Get the set "vars" of free variables in t, i.e. the symbols of sig 
     120          that t depends on 
     121    4.3 : For each "v" in vars : 
     122          4.3.1 : Add v to incl 
     123          4.3.2 : If v does not occur in done, add it to todo 
     124    4.4 : Remove v from todo and add it to done 
     125    4.5 : Go to 3 
     126 
     1275 : Let "sig1" be the subsignature of sig containing only the symbols in incl 
     128    and output the inclusion morphism m : sig1 -> sig 
     129 
     130FOR COGENERATED SIGNATURES 
     131 
     132Input : a signature "sig" and a set of symbols "syms" 
     133Output : an inclusion morphism 
     134 
     1351 : Check if all symbols in syms occur in sig; if not, output Nothing 
     136 
     1372 : Initialize the set of symbols "excl" which necessarily must be excluded 
     138    from the cogenerated signature to syms 
     139 
     1403 : For each symbol "s" in sig (keeping the order in which they are defined) : 
     141    3.1 : If s does not occur in excl : 
     142          4.1 : Get the type "t" of s in sig 
     143              4.2 : Get the set "vars" of free variables in t, i.e. the symbols of 
     144                        sig that t depends on 
     145          4.3 : If any of the symbols in vars occurs in excl, add s to excl 
     146 
     1474 : Let "sig1" be the subsignature of sig containing all the symbols not 
     148    occurring in excl and output the inclusion morphism m : sig1 -> sig 
     149-} 
    99150coGenSig :: Bool -> Set.Set Symbol -> Sign -> Result Morphism 
    100151coGenSig flag syms sig@(Sign ds) = 
     
    107158                     ds2 = filter (\ ([n],_) -> Set.member n incl) ds1 
    108159                     in inclusionMorph (Sign ds2) sig 
    109             else Result.Result [symsNotInSigError names sig] Nothing    
     160            else Result.Result [symsNotInSigError names sig] Nothing 
    110161 
    111162genSig :: Set.Set NAME -> Set.Set NAME -> Set.Set NAME -> Sign -> Set.Set NAME 
    112163genSig incl done todo sig = 
    113164  if (Set.null todo) 
    114      then incl    
     165     then incl 
    115166     else let n = Set.findMin todo 
    116167              Just t = getSymbolType n sig 
     
    123174 
    124175cogSig :: Set.Set NAME -> [DECL] -> Sign -> Set.Set NAME 
    125 cogSig incl [] sig = Set.difference (getSymbols sig) incl  
    126 cogSig incl (([n],t):ds) sig = 
    127   if (Set.member n incl) 
    128      then cogSig incl ds sig   
     176cogSig excl [] sig = Set.difference (getSymbols sig) excl 
     177cogSig excl (([n],t):ds) sig = 
     178  if (Set.member n excl) 
     179     then cogSig excl ds sig 
    129180     else let ns = Set.toList $ getFreeVars t 
    130               depen = or $ map (\ n1 -> Set.member n1 incl) ns  
     181              depen = or $ map (\ n1 -> Set.member n1 excl) ns 
    131182              in if depen 
    132                     then let incl1 = Set.insert n incl 
    133                              in cogSig incl1 ds sig 
    134                     else cogSig incl ds sig        
     183                    then let incl1 = Set.insert n excl 
     184                             in cogSig excl1 ds sig 
     185                    else cogSig excl ds sig 
    135186cogSig _ _ _ = Set.empty 
    136187