1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
|
set show timing off .
*** check renaming instantiation
*** trivial case: no parameterized sorts in renaming
fmod FOO{X :: TRIV, Y :: TRIV} is
sort Foo{X,Y} .
op f : Bool -> Bool .
endfm
fmod BAR{Z :: TRIV} is
inc FOO{Z, Nat} .
endfm
fmod BAZ is
inc (BAR * (op f : Bool -> Bool to g)){Rat} .
endfm
show all .
show modules .
*** parameterized sorts in renaming
fmod FOO{X :: TRIV, Y :: TRIV} is
sort Foo{X,Y} .
op f : Foo{X,Y} -> Foo{X,Y} .
endfm
fmod BAR{Z :: TRIV} is
inc FOO{Z, Nat} .
endfm
fmod BAZ is
inc (BAR * (sort Foo{Z, Nat} to Bar{Nat, Z},
op f : Foo{Z, Nat} -> Foo{Z, Nat} to g)
){Rat} .
endfm
show all .
show modules .
*** parameter has the same name
fmod FOO{X :: TRIV, Y :: TRIV} is
sort Foo{X,Y} .
op f : Foo{X,Y} -> Foo{X,Y} .
endfm
fmod BAR{X :: TRIV} is
inc FOO{X, Nat} .
endfm
fmod BAZ is
inc (BAR * (sort Foo{X, Nat} to Bar{Nat, X},
op f : Foo{X, Nat} -> Foo{X, Nat} to g)
){Rat} .
endfm
show all .
show modules .
*** recapture of bound parameters instantiated by a theory-view
fmod FOO{X :: TRIV} is
sort Foo{X} .
op f : Foo{X} -> Foo{X} .
endfm
fmod BAR{X :: TRIV} is
inc FOO{X} .
sort Bar{X} .
op g : Bar{X} -> Foo{X} .
endfm
fmod BAZ is
inc (BAR * (sort Foo{X} to Foo'{X},
sort Bar{X} to Bar'{X},
op f : Foo{X} -> Foo{X} to f',
op g : Bar{X} -> Foo{X} to g')
){STRICT-WEAK-ORDER}{STRICT-TOTAL-ORDER}{Nat<} .
endfm
show all .
show modules .
*** op->term mappings
fth T is
sort Elt .
op f : Elt -> Elt .
endfth
fmod M{X :: T} is
op g : X$Elt -> X$Elt .
var A : X$Elt .
eq g(A) = f(f(A)) .
endfm
view V from T to NAT is
sort Elt to Nat .
op f(X:Elt) to term X:Nat + 1 .
endv
fmod TEST is
inc M{V} .
endfm
show all .
*** with terms occuring as identities
fth T is
sort Elt .
op s : Elt -> Elt .
op 0 : -> Elt .
endfth
fmod M{X :: T} is
op _#_ : X$Elt X$Elt -> X$Elt [id: s(0)] .
vars A B : X$Elt .
eq s(A) # s(B) = s(s(A # B)) .
endfm
view V from T to NAT is
sort Elt to Nat .
op s(X:Elt) to term s X:Nat .
endv
fmod TEST is
inc M{V} .
endfm
show all .
red 0 # 1 .
**** mapping iter ops to terms
fth T is
sort Elt .
op s : Elt -> Elt [iter] .
op 0 : -> Elt .
endfth
fmod M{X :: T} is
op f : X$Elt -> X$Elt .
var A : X$Elt .
eq f(A) = s^10(A) .
endfm
view V from T to INT is
sort Elt to Int .
op s(X:Elt) to term - X:Int .
endv
fmod TEST is
inc M{V} .
endfm
show all .
fth T is
sort Elt .
op s : Elt -> Elt [iter] .
op 0 : -> Elt .
endfth
fmod M{X :: T} is
op f : X$Elt -> X$Elt .
var A : X$Elt .
eq f(A) = s^3(A) .
endfm
view V from T to INT is
sort Elt to Int .
op s(X:Elt) to term X:Int * X:Int .
endv
fmod TEST is
inc M{V} .
endfm
show all .
**** mapping assoc ops to terms
fth T is
sort Elt .
op f : Elt Elt -> Elt [assoc] .
endfth
fmod M{X :: T} is
op g : X$Elt X$Elt -> X$Elt .
vars A B : X$Elt .
eq g(A, B) = f(A, B, A, B) .
endfm
view V from T to NAT is
sort Elt to Nat .
op f(X:Elt, Y:Elt) to term X:Nat + Y:Nat .
endv
fmod TEST is
inc M{V} .
endfm
show all .
fth T is
sort Elt .
op f : Elt Elt -> Elt [assoc] .
endfth
fmod M{X :: T} is
op g : X$Elt X$Elt -> X$Elt .
vars A B : X$Elt .
eq g(A, B) = f(A, B, A, B) .
endfm
view V from T to INT is
sort Elt to Int .
op f(X:Elt, Y:Elt) to term X:Int - s Y:Int .
endv
fmod TEST is
inc M{V} .
endfm
show all .
set print mixfix off .
show all .
set print mixfix on .
**** mapping AC ops to terms
fth T is
sort Elt .
op f : Elt Elt -> Elt [assoc comm] .
endfth
fmod M{X :: T} is
op g : X$Elt X$Elt -> X$Elt .
vars A B : X$Elt .
eq g(A, B) = f(A, B, A, B) .
endfm
show all .
view V from T to NAT is
sort Elt to Nat .
op f(X:Elt, Y:Elt) to term X:Nat + Y:Nat .
endv
fmod TEST is
inc M{V} .
endfm
show all .
set print mixfix off .
show all .
fth T is
sort Elt .
op f : Elt Elt -> Elt [assoc comm] .
endfth
fmod M{X :: T} is
op g : X$Elt X$Elt -> X$Elt .
vars A B : X$Elt .
eq g(A, B) = f(A, B, A, B) .
endfm
show all .
view V from T to INT is
sort Elt to Int .
op f(X:Elt, Y:Elt) to term X:Int - s Y:Int .
endv
fmod TEST is
inc M{V} .
endfm
show all .
set print mixfix off .
show all .
set print mixfix on .
*** what if toTerm contains polymorph instances?
fth T is
sort Elt .
op f : Elt Elt -> Elt [assoc comm] .
endfth
fmod M{X :: T} is
op g : X$Elt X$Elt -> X$Elt .
vars A B : X$Elt .
eq g(A, B) = f(A, B, A, B) .
endfm
show all .
view V from T to NAT is
sort Elt to Nat .
op f(X:Elt, Y:Elt) to term
if X:Nat > Y:Nat then X:Nat else Y:Nat fi .
endv
fmod TEST is
inc M{V} .
endfm
show all .
set print mixfix off .
show all .
set print mixfix off .
red g(5, 4) .
*** check handling of illegal stuff
*** summing modules with free parameters
fmod FOO{X :: TRIV} is
inc (LIST + SET){X} .
endfm
*** summing modules with bound parameters
fmod FOO{X :: TRIV} is
inc LIST{X} + SET{X} .
endfm
*** Now LEGAL
*** passing a PEM in a nonfinal instantiation
fmod FOO{X :: STRICT-WEAK-ORDER, Y :: TRIV} is
inc MAP{STRICT-WEAK-ORDER, Y}{X} .
endfm
*** illegally overriding an operator from a parameter theory
fth T is
sort Elt .
op f : Elt -> Elt .
endfth
view V from T to NAT is
sort Elt to NzNat .
op f(X:Elt) to term X:NzNat .
endv
fmod MOD{M :: T} is
op f : M$Elt -> M$Elt .
endfm
fmod TEST is
protecting MOD{V} .
endfm
|