Changeset 12749
- Timestamp:
- 29.10.2009 16:26:02 (3 weeks ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
Comorphisms/DFOL2CASL.hs (modified) (1 diff)
-
DFOL/AS_DFOL.hs (modified) (1 diff)
-
DFOL/Colimit.hs (modified) (1 diff)
-
DFOL/Morphism.hs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Comorphisms/DFOL2CASL.hs
r11854 r12749 1 {- | 2 Module : $Header$ 3 Description : Translation of first-order logic with dependent types (DFOL) to 4 CASL 5 Copyright : (c) Kristina Sojakova, DFKI Bremen 2009 6 License : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt 7 8 Maintainer : k.sojakova@jacobs-university.de 9 Stability : experimental 10 Portability : portable 11 12 Ref: K. Sojakova and F. Rabe. Translating a Dependently-Typed Logic to 13 First-Order Logic. LNCS 2009, pages 326-341. 14 -} 15 1 16 module Comorphisms.DFOL2CASL where 2 17 -
trunk/DFOL/AS_DFOL.hs
r12746 r12749 39 39 translate, 40 40 getNewName, 41 getFreeVars 41 getFreeVars 42 42 ) where 43 43 -
trunk/DFOL/Colimit.hs
r12716 r12749 9 9 Stability : experimental 10 10 Portability : portable 11 12 Algorithm description: 13 14 Input : graph where nodes are signatures and edges are morphisms 15 Output : a signature "sig" and for each input signature "sig1" a morphism 16 m : sig1 -> sig 17 18 1 : Compute the transitive and symmetric closure of the relation R induced 19 by the morphisms in the graph 20 21 2 : Initialize the output signature "sig" and collection of morphisms "M" to 22 empty 23 Initialize the set of analyzed symbols to empty 24 25 3 : 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 11 41 -} 12 42 -
trunk/DFOL/Morphism.hs
r12746 r12749 97 97 98 98 -- generated and cogenerated signatures 99 {- Algorithm description: 100 101 FOR GENERATED SIGNATURES 102 103 Input : a signature "sig" and a set of symbols "syms" 104 Output : an inclusion morphism 105 106 1 : Check if all symbols in syms occur in sig; if not, output Nothing 107 108 2 : 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 113 3 : Check if todo is empty 114 3.1 : If yes, go to 5 115 3.2 : If not, go to 4 116 117 4 : 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 127 5 : Let "sig1" be the subsignature of sig containing only the symbols in incl 128 and output the inclusion morphism m : sig1 -> sig 129 130 FOR COGENERATED SIGNATURES 131 132 Input : a signature "sig" and a set of symbols "syms" 133 Output : an inclusion morphism 134 135 1 : Check if all symbols in syms occur in sig; if not, output Nothing 136 137 2 : Initialize the set of symbols "excl" which necessarily must be excluded 138 from the cogenerated signature to syms 139 140 3 : 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 147 4 : 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 -} 99 150 coGenSig :: Bool -> Set.Set Symbol -> Sign -> Result Morphism 100 151 coGenSig flag syms sig@(Sign ds) = … … 107 158 ds2 = filter (\ ([n],_) -> Set.member n incl) ds1 108 159 in inclusionMorph (Sign ds2) sig 109 else Result.Result [symsNotInSigError names sig] Nothing 160 else Result.Result [symsNotInSigError names sig] Nothing 110 161 111 162 genSig :: Set.Set NAME -> Set.Set NAME -> Set.Set NAME -> Sign -> Set.Set NAME 112 163 genSig incl done todo sig = 113 164 if (Set.null todo) 114 then incl 165 then incl 115 166 else let n = Set.findMin todo 116 167 Just t = getSymbolType n sig … … 123 174 124 175 cogSig :: Set.Set NAME -> [DECL] -> Sign -> Set.Set NAME 125 cogSig incl [] sig = Set.difference (getSymbols sig) incl126 cogSig incl (([n],t):ds) sig =127 if (Set.member n incl)128 then cogSig incl ds sig176 cogSig excl [] sig = Set.difference (getSymbols sig) excl 177 cogSig excl (([n],t):ds) sig = 178 if (Set.member n excl) 179 then cogSig excl ds sig 129 180 else let ns = Set.toList $ getFreeVars t 130 depen = or $ map (\ n1 -> Set.member n1 incl) ns181 depen = or $ map (\ n1 -> Set.member n1 excl) ns 131 182 in if depen 132 then let incl1 = Set.insert n incl133 in cogSig incl1 ds sig134 else cogSig incl ds sig183 then let incl1 = Set.insert n excl 184 in cogSig excl1 ds sig 185 else cogSig excl ds sig 135 186 cogSig _ _ _ = Set.empty 136 187