-
Notifications
You must be signed in to change notification settings - Fork 5
Unification #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unification #48
Changes from 35 commits
ed4c5e1
89b361f
968ecbf
4cb28e5
4ab5d8b
b101cde
cfcbf44
804fae5
a0bb213
4eaa7f2
3f3e6ed
b8de7ec
1fbf524
aff2a03
08dbe00
7156c9e
5a8d716
f6fc03c
ba39089
370a3a2
f04a518
9981d9c
4cc6c3f
a6b8429
c112cb0
be42b7d
0112e50
e606073
2e9a73d
169f2b2
ed44547
490b0a0
06ee122
f0a42b4
e5d5bdc
af9dc50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| use flake | ||
| use flake . -Lv |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| Notations used in Agda Core (updated on 24/11/2025) | ||
|
|
||
| --------------------------------------------------------------------------------------------------- | ||
| symbols input via agda latex | ||
| ≡ == \equiv | ||
| ⊢ |- \vdash | ||
| ˢ ^s ^s | ||
| ∶ : \vdotdot | ||
| ◃ tw \smalltriangleleft | ||
| ∈ in \in | ||
| ⊆ sub= \subseteq | ||
| ⋈ join \bowtie | ||
| ⇒ => \Rightarrow | ||
| ⌈ cuL \lceil | ||
| ⌉ cuR \rceil | ||
| ↦ r-| \mapsto | ||
| ≟ ?= | ||
| ↣ r-> \rightarrowtail | ||
| ᵤ _u _u | ||
| --------------------------------------------------------------------------------------------------- | ||
|
|
||
| For Scopes : | ||
| α <> β α <> β Concatenation of scope α at the end of scope β | ||
| ~ α revScope α scope α reversed | ||
| α ⊆ β Sub α β α is a sub-scope of β | ||
| [ x ] singleton x Scope of one element x | ||
| x ∈ α In x α singleton x ⊆ α | ||
| x ◃ α bind x α Adds element x to scope α | ||
| α ⋈ β ≡ γ Split α β γ scope γ is a mix of elements of α and β | ||
|
|
||
| For context | ||
| Γ , x ∶ t CtxExtend Γ x t extension of context Γ where x is of type t (a type) | ||
|
|
||
| For substitution and telescope : | ||
| α ⇒ β Subst α β substitution from α to β | ||
| ⌈⌉ SNil/EmptyTel empty substitution/telescope | ||
| ⌈ x ↦ u ◃ σ ⌉ SCons {x = x} u σ extension of substitution σ where x is changed to u (a term) | ||
| ⌈ x ∶ t ◃ Δ ⌉ ExtendTel x t Δ extension of telescope Δ where x is of type t (a type) | ||
| δ₁ ≟ δ₂ ∶ Δ TelEq δ₁ δ₂ Δ telescopic equality between the scopes δ₁ = δ₂ of type Δ | ||
|
|
||
| For types : | ||
| Γ ⊢ u ∶ t TyTerm Γ u t In context Γ, u (a term) is of type t (a type) | ||
| Γ ⊢ˢ δ ∶ Δ TySubst Γ δ Δ In context Γ, δ (a substitution) is of type Δ (a telescope) | ||
|
|
||
| Unification : | ||
| Γ , ΔEq ↣ᵤ Γ' , ΔEq' UnificationStep Γ ΔEq Γ' ΔEq' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| open import Haskell.Prelude | ||
| open import Haskell.Extra.Erase | ||
| open import Haskell.Law.Equality | ||
|
|
||
| open import Scope | ||
|
|
||
|
|
||
| open import Agda.Core.Name | ||
|
|
||
| module Agda.Core.ScopeUtils where | ||
|
|
||
| module Shrink where | ||
| private variable | ||
| @0 α β : Scope Name | ||
| x : Name | ||
|
|
||
| data Shrink : (@0 α β : Scope Name) → Set where | ||
| ShNil : Shrink mempty β | ||
| ShKeep : (@0 x : Name) → Shrink α β → Shrink (x ◃ α) (x ◃ β) | ||
| ShCons : (@0 x : Name) → Shrink α β → Shrink α (x ◃ β) | ||
|
|
||
| opaque | ||
| unfolding Scope | ||
| idShrink : Rezz α → Shrink α α | ||
| idShrink (rezz []) = ShNil | ||
| idShrink (rezz (Erased x ∷ α)) = ShKeep x (idShrink (rezz α)) | ||
|
|
||
| ShrinkToSub : Shrink α β → α ⊆ β | ||
| ShrinkToSub ShNil = subEmpty | ||
| ShrinkToSub (ShKeep x s) = subBindKeep (ShrinkToSub s) | ||
| ShrinkToSub (ShCons x s) = subBindDrop (ShrinkToSub s) | ||
|
|
||
| opaque | ||
| unfolding Sub Split | ||
| SubToShrink : Rezz β → α ⊆ β → Shrink α β | ||
| SubToShrink _ (⟨ γ ⟩ EmptyL) = ShNil | ||
| SubToShrink βRun (⟨ γ ⟩ EmptyR) = idShrink βRun | ||
| SubToShrink βRun (⟨ γ ⟩ ConsL x p) = ShKeep x (SubToShrink (rezzUnbind βRun) < p >) | ||
| SubToShrink βRun (⟨ γ ⟩ ConsR y p) = ShCons y (SubToShrink (rezzUnbind βRun) < p >) | ||
| {- | ||
EwenBC marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| opaque | ||
| unfolding Sub Split SubToShrink splitEmptyLeft | ||
| ShrinkEquivLeft : (βRun : Rezz β) (s : Shrink α β) → SubToShrink βRun (ShrinkToSub s) ≡ s | ||
| ShrinkEquivLeft βRun ShNil = refl | ||
| ShrinkEquivLeft βRun (ShKeep x s) = do | ||
| let e = ShrinkEquivLeft (rezzUnbind βRun) s | ||
| subst (λ z → SubToShrink βRun (ShrinkToSub (ShKeep x s)) ≡ ShKeep x z ) e {! !} | ||
| ShrinkEquivLeft βRun (ShCons x s) = do | ||
| let e = ShrinkEquivLeft (rezzUnbind βRun) s | ||
| subst (λ z → SubToShrink βRun (ShrinkToSub (ShCons x s)) ≡ ShCons x z ) e {! !} | ||
| -} | ||
| {- End of module Shrink -} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,9 @@ open import Haskell.Prelude hiding (All; s; t) | |
| open import Haskell.Extra.Dec using (ifDec) | ||
| open import Haskell.Extra.Erase | ||
| open import Haskell.Law.Equality | ||
| open import Haskell.Law.Monoid | ||
| open import Haskell.Law.Semigroup.Def | ||
| open import Haskell.Law.Monoid.Def | ||
|
|
||
| open import Utils.Tactics using (auto) | ||
|
|
||
| open import Agda.Core.Name | ||
|
|
@@ -27,20 +29,24 @@ data Telescope (@0 α : Scope Name) : @0 Scope Name → Set where | |
| EmptyTel : Telescope α mempty | ||
| ExtendTel : (@0 x : Name) → Type α → Telescope (x ◃ α) β → Telescope α (x ◃ β) | ||
|
|
||
| pattern ⌈⌉ = EmptyTel | ||
| infix 6 ⌈_∶_◃_⌉ | ||
| pattern ⌈_∶_◃_⌉ x t Δ = ExtendTel x t Δ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My personal taste here would be to omit the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to change this notation in the pull request that I started yesterday ? (As doing so here will create a conflict between the two pull request.)
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's fine with me. |
||
|
|
||
| {-# COMPILE AGDA2HS Telescope #-} | ||
|
|
||
| opaque | ||
| unfolding Scope | ||
|
|
||
| caseTelEmpty : (tel : Telescope α mempty) | ||
| → (@0 {{tel ≡ EmptyTel}} → d) | ||
| → (@0 {{tel ≡ ⌈⌉}} → d) | ||
| → d | ||
| caseTelEmpty EmptyTel f = f | ||
| caseTelEmpty ⌈⌉ f = f | ||
|
|
||
| caseTelBind : (tel : Telescope α (x ◃ β)) | ||
| → ((a : Type α) (rest : Telescope (x ◃ α) β) → @0 {{tel ≡ ExtendTel x a rest}} → d) | ||
| → d | ||
| caseTelBind (ExtendTel _ a tel) f = f a tel | ||
| caseTelBind ⌈ _ ∶ a ◃ tel ⌉ f = f a tel | ||
|
|
||
| {-# COMPILE AGDA2HS caseTelEmpty #-} | ||
| {-# COMPILE AGDA2HS caseTelBind #-} | ||
|
|
@@ -116,8 +122,8 @@ getConstructor c d = | |
| {-# COMPILE AGDA2HS getConstructor #-} | ||
|
|
||
| weakenTel : α ⊆ γ → Telescope α β → Telescope γ β | ||
| weakenTel p EmptyTel = EmptyTel | ||
| weakenTel p (ExtendTel x ty t) = ExtendTel x (weaken p ty) (weakenTel (subBindKeep p) t) | ||
| weakenTel p ⌈⌉ = ⌈⌉ | ||
| weakenTel p ⌈ x ∶ ty ◃ t ⌉ = ⌈ x ∶ (weaken p ty) ◃ (weakenTel (subBindKeep p) t) ⌉ | ||
|
|
||
| {-# COMPILE AGDA2HS weakenTel #-} | ||
|
|
||
|
|
@@ -127,19 +133,51 @@ instance | |
| {-# COMPILE AGDA2HS iWeakenTel #-} | ||
|
|
||
| rezzTel : Telescope α β → Rezz β | ||
| rezzTel EmptyTel = rezz _ | ||
| rezzTel (ExtendTel x ty t) = rezzCong (λ t → singleton x <> t) (rezzTel t) | ||
| rezzTel ⌈⌉ = rezz _ | ||
| rezzTel ⌈ x ∶ ty ◃ t ⌉ = rezzCong (λ t → singleton x <> t) (rezzTel t) | ||
|
|
||
| {-# COMPILE AGDA2HS rezzTel #-} | ||
|
|
||
| opaque | ||
| addTel : Telescope α β → Telescope ((~ β) <> α) γ → Telescope α (β <> γ) | ||
| addTel {α = α} {γ = γ} ⌈⌉ tel0 = do | ||
| let Δ₁ : Telescope (mempty <> α) γ | ||
| Δ₁ = subst0 (λ ∅ → Telescope (∅ <> α) γ) revsIdentity tel0 | ||
| Δ₂ : Telescope α γ | ||
| Δ₂ = subst0 (λ α₀ → Telescope α₀ γ) (leftIdentity α) Δ₁ | ||
| subst0 (λ γ₀ → Telescope α γ₀) (sym (leftIdentity γ)) Δ₂ | ||
| addTel {α = α} {γ = γ} ⌈ x ∶ ty ◃ s ⌉ tel0 = do | ||
| let Δ₁ : Telescope ((~ _ ▹ x) <> α) γ | ||
| Δ₁ = subst0 (λ β₀ → Telescope (β₀ <> α) γ) (revsBindComp _ x) tel0 | ||
| Δ₂ : Telescope (~ _ <> (x ◃ α)) γ | ||
| Δ₂ = subst0 (λ α₀ → Telescope α₀ γ) (sym (associativity (~ _) [ x ] α)) Δ₁ | ||
| Ξ : Telescope (x ◃ α) (_ <> γ) | ||
| Ξ = addTel s Δ₂ | ||
| Ξ' : Telescope α (x ◃ (_ <> γ)) | ||
| Ξ' = ⌈ x ∶ ty ◃ Ξ ⌉ | ||
| @0 e : x ◃ (_ <> γ) ≡ (x ◃ _) <> γ | ||
| e = associativity [ x ] _ γ | ||
| subst0 (λ γ₀ → Telescope α γ₀) e Ξ' | ||
|
|
||
| {-# COMPILE AGDA2HS addTel #-} | ||
|
|
||
| addTelrev : Telescope α (~ β) → Telescope (β <> α) γ → Telescope α ((~ β) <> γ) | ||
| addTelrev {α = α} {β = β} {γ = γ} sigma delta = do | ||
| let Δ₁ : Telescope (~ ~ β <> α) γ | ||
| Δ₁ = subst0 (λ β₀ → Telescope (β₀ <> α) γ) (sym (revsInvolution β)) delta | ||
| addTel sigma Δ₁ | ||
|
|
||
| {-# COMPILE AGDA2HS addTelrev #-} | ||
|
|
||
| {- | ||
| addTel : Telescope α β → Telescope ((revScope β) <> α) γ → Telescope α (β <> γ) | ||
| addTel EmptyTel t = | ||
| subst0 (Telescope _) | ||
| (sym (leftIdentity _)) | ||
| (subst0 (λ s → Telescope s _) | ||
| (trans (cong (λ t → t <> _) | ||
| revScopeMempty) | ||
| (leftIdentity _)) | ||
| t) | ||
| addTel (ExtendTel x ty s) t = {!!} -} | ||
| opaque | ||
| unfolding revScope | ||
| addTel : Telescope α β → Telescope ((~ β) <> α) γ → Telescope α (β <> γ) | ||
| addTel ⌈⌉ Δ = Δ | ||
| addTel {α = α} {β = _ ∷ β} {γ = γ} ⌈ x ∶ ty ◃ Σ ⌉ Δ = do | ||
| let Δ₁ : Telescope ((~ β ▹ x) <> α) γ | ||
| Δ₁ = subst0 (λ β₀ → Telescope (β₀ <> α) γ) (revsBindComp β x) Δ | ||
| Δ₂ : Telescope (~ β <> (x ◃ α)) γ | ||
| Δ₂ = subst0 (λ α₀ → Telescope α₀ γ) (sym (associativity (~ β) [ x ] α)) Δ₁ | ||
| ⌈ x ∶ ty ◃ addTel Σ Δ₂ ⌉ | ||
| -} | ||
Uh oh!
There was an error while loading. Please reload this page.