PAIR A with A A Bool undef A
PAIR (A with { - == -: A, A Bool; undef : A}, B with { - == -: B, B Bool; undef : B}) sort Pair constants undef : Pair uses BOOLEAN first : Pair A second : Pair B pair : A, B Pair - == - : Pair, Pair Bool pair(undef, undef) = undef pair(x, y) == pair(u, v) = (x == u) and (y == v) first(pair(x, y)) =x second(pair(x, y)) = y
QUAD (A with { - == -: A, A Bool; undef : A}, B with { - == -: B, B Bool; undef : B}, C with { - == -: C, C Bool; undef : C}, D with { - == -: D, D Bool; undef : D}) sort Quad constants undef : Quad uses BOOLEAN first second third fourth Quad - == - : Quad A : Quad B : Quad C : Quad D : A, B, C, D Quad : Quad, Quad Bool
Quad(undef, undef) = undef Quad(a, b, c, d) == Quad(u, v, w, x) = (a == u) and (b == v) and (c == w) and (d == x) first(Quad(a, b, c, d)) =a second(Quad(a, b, c, d)) =b third(Quad(a, b, c, d)) =c fourth(Quad(a, b, c, d)) =d
BIMAP (src with { -==- : src, src Bool}, targ 1 with {-==- : targ 1, targ 1 Bool; undef : targ 1}, targ 2 with {-==- : targ 2, targ 2 Bool; undef : targ 2}) sort Bimap uses BOOLEAN pair 1 = PAIR(src, targ 1), pair 2 = PAIR(src, targ 2) list 1 = LIST(pair 1), list 2 = LIST(pair 2) constants undef : Bimap
BIMAP if-then-elseif-then-else-==<-, -, ->*-[- -]1 -[- -]2 retrieve 1 retrieve 2 list 1 list 2 : Bool, Bimap : Bool, targ 1 : Bool, targ 2, atrg 2 targ 2 : Bimap, Bimap Bool : scr, targ 1, targ 2, Bimap : Bimap, src, targ 1 Bimap : Bimap, src, targ 2 Bimap : Bimap, src targ 1 : Bimap, src targ 2 : Bimap list 1 : Bimap list 2
BIMAP if true then a else b = a if false then a else b = b (undef : Bimap) == (undef : Bimap) = true <s, t 1, t 2> * b == <s’, t 1’, t 2’> * b’ = (s == s’) and (t 1 == t 1’) and (b == b’) and (t 2 == t 2’) <s, t 1, t 2> * b == undef = false undef == <s, t 1, t 2> * b = false undef [s t]1 = undef [s t]2 = undef (<s, t 1, t 2> * b)[s’ t]1 = if s == s’ then <s, t, t 2> *b else <s, t 1, t 2> *b[s’ t]1 (<s, t 1, t 2> * b)[s’ t]2 = if s == s’ then <s, t 1, t> *b else <s, t 1, t 2> *b[s’ t]2
BIMAP retrieve 1 (undef, x) = undef retrieve 2 (undef, x) = undef retrieve 1 (<s, t 1, t 2> * b, x) = if s == x then t 1 else retrieve 1(b, x) retrieve 2 (<s, t 1, t 2> * b, x) = if s == x then t 2 else retrieve 2(b, x) list 1(undef) = 0 list 2(undef) = 0 list 1(<s, t 1, t 2> *b) = pair(s, t 1). list 1(b) list 2(<s, t 1, t 2> *b) = pair(s, t 2). list 2(b)
- Slides: 7