Skip to content

Add arrays to metatheory #7127

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Add arrays to metatheory #7127

wants to merge 14 commits into from

Conversation

ramsay-t
Copy link
Contributor

@ramsay-t ramsay-t commented May 30, 2025

@ramsay-t ramsay-t added the No Changelog Required Add this to skip the Changelog Check label May 30, 2025
Copy link
Contributor

github-actions bot commented Jun 12, 2025

PR Preview Action v1.6.1

🚀 View preview at
https://IntersectMBO.github.io/plutus/pr-preview/pr-7127/

Built to branch gh-pages at 2025-06-22 03:35 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Contributor

@ana-pantilie ana-pantilie left a comment

Choose a reason for hiding this comment

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

Happy that the typeclass FFI stuff helped!
If I understand correctly, you've managed to find a way to pass the correct Eq instance to eqArray with the {{HE}} thing, right?

I have some minor comments.

Also, there are some Haskell modules in the metatheory in which I had to match on builtins and added error to the array cases. Those should be fixed in this PR as well.

Comment on lines +99 to +102
-- Arrays
lengthOfArray : Builtin
listToArray : Builtin
indexArray : Builtin
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking: indentation

Comment on lines +302 to +304
signature lengthOfArray = ∀a [ array a ]⟶ integer ↑
signature listToArray = ∀a [ list a ]⟶ array a
signature indexArray = ∀a [ array a , integer ↑ ]⟶ a ↑
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking: indentation again 😁

@@ -0,0 +1,27 @@
module MinBS where
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be checked in?

@@ -85,6 +84,7 @@ data Tag : Set → Set where
pdata : Tag (Esc DATA)
pair : ∀{A B} → Tag (Esc A) → Tag (Esc B) → Tag (Esc (A × B))
list : ∀{A} → Tag (Esc A) → Tag (Esc (List A))
array : ∀{A} → Tag (Esc A) → Tag (Esc (Array A))
Copy link
Contributor

Choose a reason for hiding this comment

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

Now I'm wondering whether GitHub is messing up the indentation. If that's the case then please ignore all my nitpicking.

@@ -98,6 +98,7 @@ data Tag : Set → Set where
{-# FOREIGN GHC pattern TagData = DefaultUniData #-}
{-# FOREIGN GHC pattern TagPair ta tb = DefaultUniPair ta tb #-}
{-# FOREIGN GHC pattern TagList ta = DefaultUniList ta #-}
{-# FOREIGN GHC pattern TagArray ta = DefaultUniArray ta #-}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@@ -136,22 +184,26 @@ decTagCon' unit ⊤ unit ⊤ = true
decTagCon' pdata d pdata d' = eqDATA d d'
decTagCon' (pair t₁ t₂) (x₁ , x₂) (pair u₁ u₂) (y₁ , y₂) = decTagCon' t₁ x₁ u₁ y₁
∧ decTagCon' t₂ x₂ u₂ y₂
decTagCon' (list t) [] (list t') [] = true -- TODO: check that the tags t and t' are equal
decTagCon' (list t) [] (list t') [] = true -- FIXME: Should compare tags
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add an issue which tracks this and add the link here.

decTagCon' (list t) (x ∷ xs) (list t') (y ∷ ys) = decTagCon' t x t' y
∧ decTagCon' (list t) xs (list t') ys
decTagCon' (array t) x (array t') y = false -- FIXME: eqArray
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add an issue which tracks this and add the link here.

Comment on lines +201 to +202
HsEqArray : {A : Set} {{HE : HasEq A}} {{ _ : HsEq A}} → HsEq (U.Array A)
HsEqArray {{HE = HE}} = record { hsEq = eqArray {{HE}}}
Copy link
Contributor

Choose a reason for hiding this comment

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

😮 cool!

@@ -251,21 +262,24 @@ decEq-⟦ _⊢♯.list t ⟧tag (x U.∷ v) (x₁ U.∷ v₁) with decEq-⟦ t
... | yes refl with decEq-⟦ _⊢♯.list t ⟧tag v v₁
... | yes refl = yes refl
... | no ¬v=v₁ = no λ { refl → ¬v=v₁ refl }
decEq-⟦ _⊢♯.pair t t₁ ⟧tag (proj₁ U., proj₂) (proj₃ U., proj₄) with (decEq-⟦ t ⟧tag proj₁ proj₃) ×-dec (decEq-⟦ t ⟧tag proj₂ proj₄)
decEq-⟦ _⊢♯.array t ⟧tag = decEq-Array-TyTag {t} decEq-⟦ t ⟧tag
Copy link
Contributor

Choose a reason for hiding this comment

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

Since decEq-Array-TyTag is postulated and doesn't have a Haskell definition, won't this crash at runtime?


postulate
instance
hasEq-TyTag : {t : TyTag} → HasEq ⟦ t ⟧tag
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you use this anywhere?

@ramsay-t ramsay-t marked this pull request as ready for review June 23, 2025 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No Changelog Required Add this to skip the Changelog Check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants