Closed joey-coleman closed 10 years ago
Comment by nick_battle, 2011-11-18 12:27:08:
This is an interesting proposal. What would happen with pattern bindings where there is an ambiguity in the map's domain, like "let {a |-> 2} = {1 |-> 2, 2 |-> 2} in a"? I suppose that would be a new case of looseness ("a" could be 1 or 2)? And so in expressions where all possibilities are considered (like exists and forall), all bindings would be tested?
Comment by shinsahara, 2011-11-20 03:54:01:
"let {a |-> 2} = {1 |-> 2, 2 |-> 2} in a" becomes run-time error. This is same as "let {a} = {1,2} in a"
"let { a |-> 2, b |-> 2 } = {1 |-> 2, 2 |-> 2} in a" => (a= 1, b=2) or (a = 2 or b = 1)
Comment by shinsahara, 2012-02-01 04:36:33:
specification of map pattern
Files were attached:
- MapPattern.rtf (13917 bytes)
Comment by nick_battle, 2012-02-01 09:07:47:
Presumably the map override pattern is trying to provide the same "partitioning" ability as the sequence concatenation and set union patterns? So why isn't it a "munion" pattern? The ++ override implies that the RHS can replace domain items on the LHS, but munion does not (overlaps are an error).
Comment by shinsahara, 2012-02-02 02:05:16:
Dr.k thinks "++" is shorter than "munion" :-) And, following are same effect and meaning, because RHS should be a map. let m1 munion m2 = aMap in ... let m1 ++ m2 = aMap in ...
Comment by nick_battle, 2012-02-02 08:02:04:
Well, I agree it's shorter(!), but intuitively the ++ override operator has the wrong semantic implication. The LHS and RHS are not chosen so that m1 ++ m2 = m after the match, they are chosen so that m1 munion m2 = m, surely? (I agree the result would be the same, but you see my point? ++ and munion mean different things).
Comment by shinsahara, 2012-02-06 02:32:07:
Dr.k was persuaded to "++" -> "munion".
So, map merge pattern = pattern, 'munion', pattern;
Comment by nick_battle, 2012-04-16 17:47:32:
Should the maplet pattern list allow the empty map to be defined? Comparing this to set enum and sequence enum patterns, you ought to be able to match against the empty map as you can with the empty sequence and set. Do you agree (and does the VDMTools implementation do this?)
map enum pattern = '{', maplet pattern list, '}' | ' {', '|->', '}';
Comment by shinsahara, 2012-04-17 01:46:27:
Dr. Kei Sato and I agree following:
map enum pattern = '{', maplet pattern list, '}' | ' {', '|->', '}';
Comment by nick_battle, 2012-09-09 11:56:13.515000:
- lrm_updated: --> False
- vdmj_implementation: --> Available in 1.2.1
- milestone: Discussion --> Execution
Comment by shinsahara, 2012-10-14 08:42:35.056000:
I've modified "++" to minion.
implemented in overturetool/overture@0b89dbb5b34ff45aabb6064fd6b839dd0aeb3020
map override pattern = pattern, '++', pattern;
A map enumeration pattern fits only map values. The maplet patterns are matched to distinct elements of a map; all elements must be matched.
A map override pattern fits only map values. The two patterns are matched to a partition of two sub maps of a map. In the Toolbox the two sub maps will always be chosen such that they are non-empty and disjoint.
(b) benefits from the modification: Same as 3. (c) possible side effects: Probably, side effects occur on Proof
d let { 1 |-> a } = { 1 |-> 2 } in a 2
d let { 1 |-> a, a |-> b, b |-> c } = { 1 |-> 4, 2 |-> 3, 4 |-> 2 } in c 3
d { a | { 1 |-> a } ++ - in set { { 1 |-> 2, 3 |-> 5, 6 |-> 'a' } } } { 2 }