2015-04-01 19:36:33 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Author: Jeremy Avigad
|
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
Extensional equality for functions, and a proof of function extensionality from quotients.
|
2015-04-01 19:36:33 +00:00
|
|
|
-/
|
|
|
|
prelude
|
2015-04-01 20:05:05 +00:00
|
|
|
import init.quot init.logic
|
2015-04-01 19:36:33 +00:00
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
namespace function
|
2015-04-01 19:36:33 +00:00
|
|
|
variables {A : Type} {B : A → Type}
|
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
protected definition equiv (f₁ f₂ : Πx : A, B x) : Prop := ∀x, f₁ x = f₂ x
|
2015-04-01 19:36:33 +00:00
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
namespace equiv_notation
|
|
|
|
infix `~` := function.equiv
|
|
|
|
end equiv_notation
|
|
|
|
open equiv_notation
|
2015-04-01 19:36:33 +00:00
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
protected theorem equiv.refl (f : Πx : A, B x) : f ~ f := take x, rfl
|
2015-04-01 19:36:33 +00:00
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
protected theorem equiv.symm {f₁ f₂ : Πx: A, B x} : f₁ ~ f₂ → f₂ ~ f₁ :=
|
2015-04-01 19:36:33 +00:00
|
|
|
λH x, eq.symm (H x)
|
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
protected theorem equiv.trans {f₁ f₂ f₃ : Πx: A, B x} : f₁ ~ f₂ → f₂ ~ f₃ → f₁ ~ f₃ :=
|
2015-04-01 19:36:33 +00:00
|
|
|
λH₁ H₂ x, eq.trans (H₁ x) (H₂ x)
|
|
|
|
|
2015-05-19 05:35:18 +00:00
|
|
|
protected theorem equiv.is_equivalence (A : Type) (B : A → Type) : equivalence (@function.equiv A B) :=
|
|
|
|
mk_equivalence (@function.equiv A B) (@equiv.refl A B) (@equiv.symm A B) (@equiv.trans A B)
|
2015-04-07 13:39:50 +00:00
|
|
|
end function
|
2015-04-01 19:36:33 +00:00
|
|
|
|
2015-04-22 02:13:19 +00:00
|
|
|
section
|
2015-04-07 13:39:50 +00:00
|
|
|
open quot
|
|
|
|
variables {A : Type} {B : A → Type}
|
2015-04-01 19:36:33 +00:00
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
private definition fun_setoid [instance] (A : Type) (B : A → Type) : setoid (Πx : A, B x) :=
|
|
|
|
setoid.mk (@function.equiv A B) (function.equiv.is_equivalence A B)
|
|
|
|
|
|
|
|
private definition extfun (A : Type) (B : A → Type) : Type :=
|
2015-04-01 19:36:33 +00:00
|
|
|
quot (fun_setoid A B)
|
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
private definition fun_to_extfun (f : Πx : A, B x) : extfun A B :=
|
2015-04-01 19:36:33 +00:00
|
|
|
⟦f⟧
|
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
private definition extfun_app (f : extfun A B) : Πx : A, B x :=
|
2015-04-01 19:36:33 +00:00
|
|
|
take x,
|
|
|
|
quot.lift_on f
|
|
|
|
(λf : Πx : A, B x, f x)
|
|
|
|
(λf₁ f₂ H, H x)
|
|
|
|
|
|
|
|
theorem funext {f₁ f₂ : Πx : A, B x} : (∀x, f₁ x = f₂ x) → f₁ = f₂ :=
|
|
|
|
assume H, calc
|
2015-04-07 13:39:50 +00:00
|
|
|
f₁ = extfun_app ⟦f₁⟧ : rfl
|
|
|
|
... = extfun_app ⟦f₂⟧ : {sound H}
|
2015-04-29 21:39:59 +00:00
|
|
|
... = f₂ : rfl
|
2015-04-01 19:36:33 +00:00
|
|
|
end
|
2015-04-01 20:05:05 +00:00
|
|
|
|
2015-12-08 05:33:35 +00:00
|
|
|
attribute funext [intro!]
|
2015-12-08 01:08:32 +00:00
|
|
|
|
2015-04-07 13:39:50 +00:00
|
|
|
open function.equiv_notation
|
|
|
|
|
|
|
|
definition subsingleton_pi [instance] {A : Type} {B : A → Type} (H : ∀ a, subsingleton (B a)) :
|
|
|
|
subsingleton (Π a, B a) :=
|
2015-04-01 20:05:05 +00:00
|
|
|
subsingleton.intro (take f₁ f₂,
|
|
|
|
have eqv : f₁ ~ f₂, from
|
|
|
|
take a, subsingleton.elim (f₁ a) (f₂ a),
|
|
|
|
funext eqv)
|