Axioms on equality
The quotient axiom and propositional extensionality postulate equality assuming equivalence. They differ in the nature of the equivalence.
The quotient axiom asserts that β¦xβ§ = β¦yβ§ if x β y.
#print Quot.sound
example (Ξ± : Sort u) (r : Ξ± β Ξ± β Prop) (x y : Ξ±)
(h : r x y)
: Quot.mk r x = Quot.mk r y
:= Quot.sound h
We will show below that the quotient axiom implies function extensionality.
The axiom of propositional extensionality asserts that p = q if p β q.
#print propext
example (p q : Prop)
(h : p β q)
: p = q
:= propext h
We will show below that propositional extensionality implies quotient exactness.
Here is a small example illustrating that Lean tracks the axioms that each proof depends on.
lemma t_eq_notf : True = Β¬False
:= propext β¨Ξ» h β¦ id, Ξ» h β¦ trivialβ©
#print axioms t_eq_notf
Function extensionality
Recall that function extensionality is formulated as follows.
#print funext
#print axioms funext
example (Ξ± : Sort u) (Ξ² : Ξ± β Sort v) (f g : (x : Ξ±) β Ξ² x)
(h : β x, f x = g x)
: f = g
:= funext h
The proof of funext is based on defining an equivalence of functions by β x, f x = g x, lifting function application on the equivalence classes, and using the quotient axiom together with the quotient reduction.
example (Ξ± : Sort u) (Ξ² : Ξ± β Sort v) (f g : (x : Ξ±) β Ξ² x)
(h : β x, f x = g x)
: f = g
:=
-- Definition of a setoid of functions
let Ξ¦ := (x : Ξ±) β Ξ² x
let r (Οβ Οβ : Ξ¦) := β x, Οβ x = Οβ x
have r_refl (Ο : Ξ¦) : r Ο Ο
:= Ξ» x β¦ rfl
have r_symm {Οβ Οβ : Ξ¦} (h : r Οβ Οβ) : r Οβ Οβ
:= Ξ» x β¦ (h x).symm
have r_trans {Οβ Οβ Οβ : Ξ¦} (h1 : r Οβ Οβ) (h2 : r Οβ Οβ)
: r Οβ Οβ
:= Ξ» x β¦ calc
Οβ x
_ = Οβ x := h1 x
_ = Οβ x := h2 x
let s : Setoid Ξ¦ := β¨r, β¨r_refl, r_symm, r_transβ©β©
-- Lift of function application
let lifted_app (Ο : Quotient s) (x : Ξ±) :=
have {Οβ Οβ : Ξ¦} (h : Οβ β Οβ) : Οβ x = Οβ x := h x
Quotient.lift (Ξ» Ο β¦ Ο x) (Ξ» _ _ h β¦ this h) Ο
-- Use the quotient axiom
have : β¦fβ§ = β¦gβ§ := Quotient.sound h
-- Use the quotient reduction
calc
f = lifted_app β¦fβ§ := rfl
_ = lifted_app β¦gβ§ := congrArg lifted_app this
_ = g := rfl
Quotient exactness
Recall that Quotient.exact is the implication converse to Quotient.sound.
#print Quotient.exact
#print axioms Quotient.exact
example (Ξ± : Sort u) (s : Setoid Ξ±) (aβ aβ : Ξ±)
(h : (β¦aββ§ : Quotient s) = β¦aββ§)
: aβ β aβ
:= Quotient.exact h
The proof of Quotient.exact is based on turning the logical equivalence in the below lemma eqv_iff into equality using propext. In order to use β in calc blocks, we declare a local instance of Trans.
open Setoid in
lemma eqv_iff {Ξ± : Sort u} {s : Setoid Ξ±} {xβ yβ xβ yβ : Ξ±}
(hx : xβ β xβ) (hy: yβ β yβ)
: (xβ β yβ) β (xβ β yβ)
:=
let : Trans (Ξ± := Ξ±) (Β· β Β·) (Β· β Β·) (Β· β Β·) := β¨transβ©
have mp := Ξ» h β¦ calc
xβ
_ β xβ := symm hx
_ β yβ := h
_ β yβ := hy
have mpr := Ξ» h β¦ calc
xβ
_ β xβ := hx
_ β yβ := h
_ β yβ := symm hy
β¨mp, mprβ©
We now prove Quotient.exact by lifting β and using the recursor of =.
example (Ξ± : Sort u) (s : Setoid Ξ±) (aβ aβ : Ξ±)
(h : (β¦aββ§ : Quotient s) = β¦aββ§)
: aβ β aβ
:=
let lifted_eqv (qβ qβ : Quotient s) : Prop :=
Quotient.liftβ
(Ξ» x y β¦ x β y)
(Ξ» _ _ _ _ hx hy β¦ propext (eqv_iff hx hy))
qβ qβ
let qβ := β¦aββ§
have : lifted_eqv qβ qβ :=
Quotient.ind (motive := Ξ» q β¦ lifted_eqv q q) s.refl qβ
Eq.rec (motive := Ξ» q _ β¦ lifted_eqv qβ q) this h