Skip to content

Updated Pure definition in the metatheory #6964

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

Merged
merged 24 commits into from
Apr 8, 2025
Merged

Conversation

ramsay-t
Copy link
Contributor

@ramsay-t ramsay-t commented Mar 20, 2025

The previous Pure definition was just a stub. This works, although there are some differences from the Haskell and some open questions about some of the details.

@ramsay-t ramsay-t requested a review from effectfully March 20, 2025 12:50
@ramsay-t ramsay-t added the No Changelog Required Add this to skip the Changelog Check label Mar 20, 2025
@ramsay-t
Copy link
Contributor Author

Currently this definition of Purity also causes the certifier to say "no" to some of the tests. We should, obviously, fix that before we merge this.

-- case applied to constr would reduce, and possibly be pure.
case : {i : ℕ} {t : X ⊢}{vs ts : List (X ⊢)}
→ lookup? i ts ≡ just t
→ Pure t
Copy link
Contributor

Choose a reason for hiding this comment

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

No, it's t applied to vs that needs to be Pure.

Anyway, do feel free to just omit case. Perhaps with a comment of what we discussed here.

sat-det sat-t sat-t₁ refl = trans (sym sat-t) sat-t₁

data Pure {X : Set} : (X ⊢) → Set where
force : {t : X ⊢} → Pure t → Pure (force t)
Copy link
Contributor

Choose a reason for hiding this comment

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

No, delay b is pure, force (delay b) isn't necessarily pure. Except when b is pure, which you also need to handle, because the implementation does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did we agree that we only force delays (and builtins), so we don't need to handle force applied to arbitrary things?


unsat-builtin : {t₁ t₂ : X ⊢} {arity args : ℕ}
→ saturation t₁ ≡ just (arity , args)
→ arity > (suc args)
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't take wrong interleaving into account, I'll write it up separately.

But it complies with the current (wrong) implementation, so it's fine.


unsat-builtin : {t₁ t₂ : X ⊢} {arity args : ℕ}
→ saturation t₁ ≡ just (arity , args)
→ arity > (suc args)
Copy link
Contributor

Choose a reason for hiding this comment

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

Still wrong as per the previous discussion. Apply IfThenElse True is impure, because it fails due to a missing force, but this logic here doesn't recognize that.

The implementation is being fixed.

unsat-builtin₀ : {t : X ⊢} {a₀ a₁ : ℕ}
→ sat t ≡ want (suc (suc a₀)) a₁
→ Pure t
→ Pure (force t)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the builtin only takes one type argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a valid question...

→ sat t ≡ want zero (suc (suc a₁))
→ Pure t
→ Pure t₁
→ Pure (t · t₁)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the builtin takes only one term argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then nothing applied to it will be pure! :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Worth a comment for dummies like myself.

Comment on lines 58 to 59
... | want zero (suc zero) = want zero zero
... | want zero (suc (suc a₁)) = want zero (suc a₁)
Copy link
Contributor

Choose a reason for hiding this comment

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

These two look like they can be a single want zero (suc a1) clause?

Copy link
Contributor

@effectfully effectfully left a comment

Choose a reason for hiding this comment

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

LGTM, feel free to hit "merge".

→ sat t ≡ want zero (suc (suc a₁))
→ Pure t
→ Pure t₁
→ Pure (t · t₁)
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth a comment for dummies like myself.

@effectfully effectfully enabled auto-merge (squash) April 8, 2025 10:58
@effectfully effectfully merged commit 1289964 into master Apr 8, 2025
7 checks passed
@effectfully effectfully deleted the ramsay-t/untyped-pure branch April 8, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Metatheory No Changelog Required Add this to skip the Changelog Check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants