Hi all,
In a formalization I'm looking at they are making an implicit assumption that I find hard to encode. They define a merge operator "|" for maps from integers to some object. This merging operator is only defined if the key sets of both maps do not overlap, otherwise the results is undefined. After that, they state that, "wherever "|" is used, we implicitly assume the keysets do not overlap". I see three options here if I want to write this in Isabelle:
Is option 3 the way to go? Or are there other options I might be missing? I'd also be interested to see any formalizations where they also had this problem, to see how they solved it.
what about an option 4: pick a reasonable default for the case where keys overlap (for example, make it equal to the output from q
always), in a way that makes as many of your lemmas as easy/unconditional as possible?
The book relies a bit on commutativity, associativity, which would no longer be the case with such a rule. I think you can probably make it work but then I would worry about my results corresponding to the results in the book...
Option 1 is never going to work (you need dependent types to do that). If the order is only used for proofs, I would go for option 2 and make the transformation explicit (like value + Max_vaule (lhs)). Otherwise, I would use 3 (because this matches what is happening here: you make explicit something implicit but you do not assume more than before)
BTW instead of returning undefined, you could just let the merge operator do something, but not caring about the result
So there is no need for a special case
Mathias Fleury said:
BTW instead of returning undefined, you could just let the merge operator do something, but not caring about the result
That makes sense. Is there a downside to using undefined?
I see it the other way around: there is no advantage to using undefined
actually, I now see the advantage of using undefined as the default: the commutativity and associativity laws still hold unconditionally, right?
Without undefined you save an if
Hmm, so I don't have to be afraid of my proofs depending on a known constant, instead of an unknown constant...? (Sorry, with Isabelle I'm just never sure about how paranoid I should be)
Yong Kiam said:
actually, I now see the advantage of using undefined as the default: the commutativity and associativity laws still hold unconditionally, right?
ah that is a good point
but then instead of undefined you could use some empty value, like done for division
(1/0 = 0)
Bob Rubbens said:
Hmm, so I don't have to be afraid of my proofs depending on a known constant, instead of an unknown constant...? (Sorry, with Isabelle I'm just never sure about how paranoid I should be)
in most context, you will anyway that there is no overlap…
But Yong has a good point! I did not think of that
I mean, I might forget adding this as an assumption sometimes...
Last updated: Dec 21 2024 at 16:20 UTC