Source code on Githubopen import Prelude.Init; open SetAsType
open L.Mem
open import Prelude.DecEq
open import Prelude.Setoid
open import Prelude.InfEnumerable
open import Prelude.InferenceRules
module Nominal.Support (Atom : Type) ⦃ _ : DecEq Atom ⦄ ⦃ _ : Enumerable∞ Atom ⦄ where
open import Nominal.New Atom
open import Nominal.Swap Atom
freshAtom : Atoms → Atom
freshAtom = proj₁ ∘ minFresh
freshAtom∉ : ∀ {xs : Atoms} → freshAtom xs ∉ xs
freshAtom∉ {xs} = minFresh xs .proj₂
private variable A : Type ℓ; B : Type ℓ′
module _ ⦃ _ : Swap A ⦄ ⦃ _ : ISetoid A ⦄ where
∃FinSupp FinSupp ∃Equivariant′ Equivariant′ : Pred A _
∃FinSupp x = И² λ 𝕒 𝕓 → swap 𝕓 𝕒 x ≈ x
FinSupp a = ∃ λ (xs : Atoms) →
(∀ x y → x ∉ xs → y ∉ xs → swap y x a ≈ a)
×
(∀ x y → x ∈ xs → y ∉ xs → swap y x a ≉ a)
∃Equivariant′ x = ∃ λ (fin-x : ∃FinSupp x) → fin-x .proj₁ ≡ []
Equivariant′ x = ∃ λ (fin-x : FinSupp x) → fin-x .proj₁ ≡ []
record ∃FinitelySupported (A : Type ℓ)
⦃ _ : ISetoid A ⦄ ⦃ _ : SetoidLaws A ⦄
⦃ _ : Swap A ⦄ ⦃ _ : SwapLaws A ⦄ : Typeω
where
field ∀∃fin : Unary.Universal ∃FinSupp
∃supp : A → Atoms
∃supp = proj₁ ∘ ∀∃fin
_∙∃supp = ∃supp
∃fresh∉ : (a : A) → ∃ (_∉ ∃supp a)
∃fresh∉ = minFresh ∘ ∃supp
∃fresh-var : A → Atom
∃fresh-var = proj₁ ∘ ∃fresh∉
swap-∃fresh : ∀ {𝕒 𝕓} (x : A) →
∙ 𝕒 ∉ ∃supp x
∙ 𝕓 ∉ ∃supp x
────────────────
⦅ 𝕒 ↔ 𝕓 ⦆ x ≈ x
swap-∃fresh x = flip (∀∃fin x .proj₂ _ _)
open ∃FinitelySupported ⦃...⦄ public
instance
∃FinSupp-Atom : ∃FinitelySupported Atom
∃FinSupp-Atom .∀∃fin 𝕒 = [ 𝕒 ] , λ _ _ y∉ z∉ →
swap-noop _ _ _ λ where 𝟘 → z∉ 𝟘; 𝟙 → y∉ 𝟘
∃supp-swap-atom : ∀ {𝕒 𝕓} (t : Atom) → ∃supp (swap 𝕒 𝕓 t) ⊆ 𝕒 ∷ 𝕓 ∷ t ∷ []
∃supp-swap-atom {a}{b} t
with t ≟ a
... | yes refl = λ where 𝟘 → 𝟙
... | no _
with t ≟ b
... | yes refl = λ where 𝟘 → 𝟘
... | no _ = λ where 𝟘 → 𝟚
record FinitelySupported (A : Type ℓ)
⦃ _ : ISetoid A ⦄ ⦃ _ : SetoidLaws A ⦄
⦃ _ : Swap A ⦄ ⦃ _ : SwapLaws A ⦄ : Typeω
where
field ∀fin : Unary.Universal FinSupp
supp : A → Atoms
supp = proj₁ ∘ ∀fin
_∙supp = supp
infix 4 _♯_
_♯_ : Atom → A → Type _
𝕒 ♯ x = 𝕒 ∉ supp x
fresh∉-min : (a : A) → ∃ (_∉ supp a)
fresh∉-min = fresh ∘ supp
fresh-var-min : A → Atom
fresh-var-min = proj₁ ∘ fresh∉-min
swap-fresh-min : ∀ {𝕒 𝕓} (x : A) →
∙ 𝕒 ∉ supp x
∙ 𝕓 ∉ supp x
────────────────
⦅ 𝕒 ↔ 𝕓 ⦆ x ≈ x
swap-fresh-min x = flip (∀fin x .proj₂ .proj₁ _ _)
∃fresh : ∀ (x : A) → ∃ λ 𝕒 → ∃ λ 𝕓 →
(𝕒 ♯ x)
× (𝕓 ♯ x)
× (swap 𝕓 𝕒 x ≈ x)
∃fresh x =
let xs , swap≈ , swap≉ = ∀fin x
a , a∉ = minFresh xs
b , b∉ = minFresh xs
in a , b , a∉ , b∉ , swap≈ a b a∉ b∉
open FinitelySupported ⦃...⦄ public
instance
FinSupp-Atom : FinitelySupported Atom
FinSupp-Atom .∀fin 𝕒 = [ 𝕒 ] , eq , ¬eq
where
eq : ∀ x y → x ∉ [ 𝕒 ] → y ∉ [ 𝕒 ] → swap y x 𝕒 ≈ 𝕒
eq _ _ x∉ y∉ = swap-noop _ _ _ λ where 𝟘 → y∉ 𝟘; 𝟙 → x∉ 𝟘
¬eq : ∀ x y → x ∈ [ 𝕒 ] → y ∉ [ 𝕒 ] → swap y x 𝕒 ≉ 𝕒
¬eq _ y 𝟘 y∉
rewrite ≟-refl 𝕒 | ≟-refl y
with 𝕒 ≟ y
... | yes refl = ⊥-elim $ y∉ 𝟘
... | no y≢ = ≢-sym y≢
supp-swap-atom : ∀ {𝕒 𝕓} (t : Atom) → supp (swap 𝕒 𝕓 t) ⊆ 𝕒 ∷ 𝕓 ∷ t ∷ []
supp-swap-atom {a}{b} t
with t ≟ a
... | yes refl = λ where 𝟘 → 𝟙
... | no _
with t ≟ b
... | yes refl = λ where 𝟘 → 𝟘
... | no _ = λ where 𝟘 → 𝟚