[ add ] Bool action on a RawMonoid plus properties#2450
[ add ] Bool action on a RawMonoid plus properties#2450JacquesCarette merged 11 commits intoagda:masterfrom
Bool action on a RawMonoid plus properties#2450Conversation
|
Ooops (mistake to try to abstract immediately over |
|
Conor's disembodied voice tells me we should use a non-symmetric infix symbol for this non-symmetric action. |
I'm genuinely torn over this. I understand, appreciate, and even largely agree with, the doctrine (prevalent in WG2.1) that non-symmetric/commutative operations should be given non-symmetric notation. Nevertheless, we don't insist that that a Nevertheless, I think we do ourselves (or else: type theory as a principled metalanguage for the prosecution of such doctrine) a disservice by taking the 'old-fashioned' CFG view of notation not coming a priori with a type attached. The case here, as more generally in the draft PR on You might object that the So perhaps the way out of the bottle is to tag the symbol with I guess I could live with that... modulo leaving |
MatthewDaggitt
left a comment
There was a problem hiding this comment.
Otherwise looks good.
| _∧_ : Bool → Carrier → Carrier | ||
| b ∧ x = if b then x else 0# | ||
|
|
||
| -- tail-recursive optimisation |
There was a problem hiding this comment.
optimisation of what? It doesn't seem like an optimisation of the above? What am I missing?
There was a problem hiding this comment.
As with the TCOptimised forms of (monoid) sum and multiplication, the 'optimisation' lies in avoiding having to explicitly track terms of the form x + 0# when these can be computed away instead to x... But I admit I haven't quite got my story straight yet... ;-)
There was a problem hiding this comment.
As witnessed by b∧x∙y≈b∧x+y...
There was a problem hiding this comment.
It still feels like a stretch. I do like the optimization of an action not doing a (statically known) null operation, a lot. I'm still worried that this particular case is a coincidence rather than fundamental!
There was a problem hiding this comment.
Well I think it extends to the Nat cases as well (but obscured in the current presentation, which doesn't introduce the tail-recursive forms... but see #2475 )
|
What prevents this from losing its DRAFT status? |
Off the top of my head:
All of the above are slightly beyond my capacity to think right now, so |
|
Notes to self (and any other interested parties here):
It may well be that this all needs reorganisation down the road, at which point it may be clearer (than it is to me now) what would be necessary/useful to isolate 'sensible' common abstractions. |
|
Converting back from
I never quite got as far as finding a common generalisation between the |
Bool action on a RawMonoid plus propertiesBool action on a RawMonoid plus properties
JacquesCarette
left a comment
There was a problem hiding this comment.
Thanks @gallais for this nice notation suggestions. I'm now happy with this PR.
|
Still needs a second approver... |
* Add new `Bool` action on a `RawMonoid` plus properties * response to review comments on draft * reset: `CHANGELOG` * restore: new `CHANGELOG` entries * change: notation * refactor: use new notation, plus add new lemma * refactor: tweak notation * refactor: proof following Jacques' suggestion
Prompted by @JacquesCarette 's desire to further systematise the refactoring in #2407 , this adds two operations which appear ad hoc in the normal form semantics for
IdempotentCommutativeMonoids, but are yet more instances of a(Raw)MonoidActioncf. #2348 / #2350 by analogy with the corresponding actions in the normal form semantics forCommutativeMonoids.NB
Could be left as DRAFT, pending further work cf. #2351 , but worth inviting review now, I think.
NB. possible issues:
x + n × yas well asn × x + yetc.Algebra.Solver.*Monoidetc.Algebra.Definitions.RawMonoid._×_operation etc. possible as well?