Zulip Chat Archive
Stream: maths
Topic: quotients and lifts for functions of arbitrary arity
William DeMeo (Dec 02 2018 at 04:31):
I'm trying to learn how to implement general quotient structures. Unfortunately, I've only been able to figure out how to lift unary operations. How does one lift operations of arbitrary arity?
More specifically, here's what I'm trying to do.
Given a type , and an "arity" type , an operation on of arity has the following type signature:
.
Now suppose I have an equivalence relation , and I want to lift to a -ary operation . That is, should be a -ary operation on the quotient . It's obvious how to express this mathematically:
,
where is the binary relation on induced by . That is, iff .
For example, if is -ary, then maps an -tuple of -classes to the -class .
I got this to work when is unary (so, ), by first defining the projection as quot.mk r (f a)
, and then using the built in quot.lift
, defined in quot.lean of the standard library. (The code for that is below, but it's not pretty.)
Unfortunately, this doesn't work for higher arity operations because quot.lift expects a relation and a proof of . But in the higher arity case, to say that the operation "respects" means the following:
If you provide quot.lift with that as the proof of "respecting r", the resulting lift will not be what we want.
Any ideas, pointers, suggestions would be much appreciated. Thanks!
Here's the code for the unary case. There's probably an easier way to do this, and suggestions are welcome... but I'm more interested in the general case.
parameters {α : Type*} {ρ : Type*} local notation a`/`r := quot.mk r a def πᵤ (f : α → α) (r : α → α → Prop) : α → quot r := λ a, (f a) / r def compatible_unary (f : α → α) (r : α → α → Prop) := ∀ a b, r a b → r (f a) (f b) lemma resp_proj_of_compatible_unary (f : α → α) (r : α → α → Prop) (h : compatible_unary f r) : ∀ a b, r a b → (f a)/r = (f b)/r := assume a b (h₀ : r a b), have h₃ : r (f a) (f b), from h a b h₀, show (f a)/r = (f b)/r, from quot.sound h₃ def lift_proj (f : α → α) (r : α → α → Prop) (h : compatible_unary f r) : quot r → quot r := quot.lift (πᵤ f r) (resp_proj_of_compatible_unary f r h)
Chris Hughes (Dec 02 2018 at 06:17):
One way of doing this is to put a relation on defined as . I don't think you can define a function of this type quotient.lift_onₙ (x : Π a : α, quotient (s a))
(f : (Π a : α, β a) → γ) (h : ∀ x₁ x₂ : Π a, β a,
(∀ a, x₁ a ≈ x₂ a) → f x₁ = f x₂) : γ
without choice though. There is something in data.fintype
that let's you do it computably when your indexing type is finite, but the fact that that's only defined on fintypes suggestsit might not be possible on infinite types.
Reid Barton (Dec 02 2018 at 15:08):
@William DeMeo You can use quotient.choice
in mathlib to turn a product of quotients into a quotient of the product, and then lift
on that to define a function.
Reid Barton (Dec 02 2018 at 15:09):
As far as I know you can't do this computably/without axioms, though it would be possible to implement by extending Lean.
Kevin Buzzard (Dec 02 2018 at 15:11):
By "without axioms" you just mean "without some standard axioms which are inbuilt into Lean but which break computability", right?
Reid Barton (Dec 02 2018 at 15:12):
Yes
William DeMeo (Dec 02 2018 at 16:07):
@Chris Hughes Great, thanks for the hints! I will look at data.fintype. I'd like to be able to do this computably at least for finitary operations. (By the way, just to be sure I understand your suggestions, I think you meant to put in place of in the two places where appears... correct?) Thanks again for your help!
Chris Hughes (Dec 02 2018 at 16:08):
Yes I did mean to put rho instead of alpha
William DeMeo (Dec 02 2018 at 16:11):
@William DeMeo You can use
quotient.choice
in mathlib to turn a product of quotients into a quotient of the product, and thenlift
on that to define a function.
Thanks @Reid Barton , maybe I'll try that if after I get it to work computably for fintype.
Reid Barton (Dec 02 2018 at 16:12):
https://github.com/leanprover/mathlib/commit/ddbb81389b6d6cd3d0395f474896dcd59e1ed9e4
Reid Barton (Dec 02 2018 at 16:12):
added both quotient.choice
and a computable finset
version
William DeMeo (Dec 02 2018 at 17:07):
added both
quotient.choice
and a computablefinset
version
Awesome! Thanks @Reid Barton I'll see if I can use those types to do exactly what I want. If not, I'll have to roll my own, but it's good to see these examples that show how things should be done.
Last updated: Dec 20 2023 at 11:08 UTC