Skip to content
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

Stlc theory #454

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Stlc theory #454

wants to merge 6 commits into from

Conversation

jake-87
Copy link
Contributor

@jake-87 jake-87 commented Jan 8, 2025

Description

Added a very simple STLC, alongside several properties. Still WIP.

Checklist

Before submitting a merge request, please check the items below:

  • I've read the contributing guidelines.
  • The imports of new modules have been sorted with support/sort-imports.hs (or nix run --experimental-features nix-command -f . sort-imports).
  • All new code blocks have "agda" as their language.

@Lavenza
Copy link
Member

Lavenza commented Jan 8, 2025

Pull request preview


Here is why it's called capture-avoiding: if our lambda binds the
variable name again, we don't substitute inside. In other words, the
substituion `(λ y. y) y [y := k]`{.Agda} yields `(λ y. y) k`{.Agda},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
substituion `(λ y. y) y [y := k]`{.Agda} yields `(λ y. y) k`{.Agda},
substitution `(λ y. y) y [y := k]`{.Agda} yields `(λ y. y) k`{.Agda},


```agda
data Value : Expr → Type where
v-var : ∀ n → Value (` n)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to consider open terms here? Typically, we either define values as closed terms, or include neutrals.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following off PLFA here - they appear to define them as general terms, with no closed requirement. It does seem reasonable to constrain them, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell values do not contain variables in PLFA. (They may still contain open terms like λ x. y)


```agda
`λ x f [ n := e ] with x ≡? n
... | yes _ = `λ x f
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when e contains x as a free variable? If we are treating the Nats as nominal vars, then we have accidentally performed a capture!

For instance, λ x (` y) [ y := x ] ≡ λ x (` x), yet λ a (` y) [ y := x ] ≡ λ a (` x), so substitution is no longer stable under alpha-equivalence. To fix this, you need to rename x to a variable that is not free in e when doing the substitution.

`U : Expr
```

<details><summary>Some application lemmas, for convinience.</summary>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<details><summary>Some application lemmas, for convinience.</summary>
<details><summary>Some application lemmas, for convenience.</summary>

Comment on lines 239 to 241
Here is why it's called capture-avoiding: if our lambda binds the
variable name again, we don't substitute inside. In other words, the
substituion `(λ y. y) y [y := k]`{.Agda} yields `(λ y. y) k`{.Agda},
Copy link
Member

@ncfavier ncfavier Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not actually what "capture-avoiding" refers to; see Reed's comment. The capture-avoiding part is α-renaming the λ-term we're substituting into so that its binder does not capture any of the free variables in the substitute.

Preservation states that if a well typed expression $x$ steps to another $x'$,
they have the same type (i.e., stepping preserves type.)

The first step in proving these is showing that a "proper" substituion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The first step in proving these is showing that a "proper" substituion
The first step in proving these is showing that a "proper" substitution

Γ ⊢ bd [ n := s ] ⦂ typ
```

In the case of variables, we use weakening for the substituion itself,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In the case of variables, we use weakening for the substituion itself,
In the case of variables, we use weakening for the substitution itself,

@jake-87
Copy link
Contributor Author

jake-87 commented Jan 11, 2025

I'm going to not push anything up here for a little bit while I work on the substitution problem; I feel like it's going to be quite messy while I figure it all out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants