| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Results concerning function extensionality for propositional equality |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Axiom.Extensionality.Propositional where |
| 10 |
|
| 11 |
open import Function.Base |
| 12 |
open import Level using (Level; _⊔_; suc; lift) |
| 13 |
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong) |
| 14 |
|
| 15 |
------------------------------------------------------------------------ |
| 16 |
-- Function extensionality states that if two functions are |
| 17 |
-- propositionally equal for every input, then the functions themselves |
| 18 |
-- must be propositionally equal. |
| 19 |
|
| 20 |
Extensionality : (a b : Level) → Set _ |
| 21 |
Extensionality a b = |
| 22 |
{A : Set a} {B : A → Set b} {f g : (x : A) → B x} → |
| 23 |
(∀ x → f x ≡ g x) → f ≡ g |
| 24 |
|
| 25 |
-- A variant for implicit function spaces. |
| 26 |
|
| 27 |
ExtensionalityImplicit : (a b : Level) → Set _ |
| 28 |
ExtensionalityImplicit a b = |
| 29 |
{A : Set a} {B : A → Set b} {f g : {x : A} → B x} → |
| 30 |
(∀ {x} → f {x} ≡ g {x}) → (λ {x} → f {x}) ≡ (λ {x} → g {x}) |
| 31 |
|
| 32 |
|
| 33 |
------------------------------------------------------------------------ |
| 34 |
-- Properties |
| 35 |
|
| 36 |
-- If extensionality holds for a given universe level, then it also |
| 37 |
-- holds for lower ones. |
| 38 |
|
| 39 |
lower-extensionality : ∀ {a₁ b₁} a₂ b₂ → |
| 40 |
Extensionality (a₁ ⊔ a₂) (b₁ ⊔ b₂) → |
| 41 |
Extensionality a₁ b₁ |
| 42 |
lower-extensionality a₂ b₂ ext f≡g = cong (λ h → Level.lower ∘ h ∘ lift) $ |
| 43 |
ext (cong (lift {ℓ = b₂}) ∘ f≡g ∘ Level.lower {ℓ = a₂}) |
| 44 |
|
| 45 |
-- Functional extensionality implies a form of extensionality for |
| 46 |
-- Π-types. |
| 47 |
|
| 48 |
∀-extensionality : ∀ {a b} → Extensionality a (suc b) → |
| 49 |
{A : Set a} (B₁ B₂ : A → Set b) → |
| 50 |
(∀ x → B₁ x ≡ B₂ x) → |
| 51 |
(∀ x → B₁ x) ≡ (∀ x → B₂ x) |
| 52 |
∀-extensionality ext B₁ B₂ B₁≡B₂ with ext B₁≡B₂ |
| 53 |
... | refl = refl |
| 54 |
|
| 55 |
-- Extensionality for explicit function spaces implies extensionality |
| 56 |
-- for implicit function spaces. |
| 57 |
|
| 58 |
implicit-extensionality : ∀ {a b} → |
| 59 |
Extensionality a b → |
| 60 |
ExtensionalityImplicit a b |
| 61 |
implicit-extensionality ext f≡g = cong _$- (ext (λ x → f≡g)) |