Skip to content

feat: heaplang opsem+instances#410

Draft
Kaptch wants to merge 42 commits into
leanprover-community:masterfrom
Kaptch:heaplang-opsem
Draft

feat: heaplang opsem+instances#410
Kaptch wants to merge 42 commits into
leanprover-community:masterfrom
Kaptch:heaplang-opsem

Conversation

@Kaptch
Copy link
Copy Markdown
Collaborator

@Kaptch Kaptch commented May 25, 2026

Description

Semantics of heaplang + language instance.
It also implements some bit operations on integers, definitions are copied from Mathlib, lemmas are a set of things that I thought could be useful, but honestly I have no intuition on using bit ops in heaplang.

Checklist

  • My code follows the mathlib naming and code style conventions
  • I have updated PORTING.md as appropriate
  • I have added my name to the authors section of any appropriate files

ayhon added 30 commits April 27, 2026 13:32
In the end, it seems like around `40` is quite a good precedence level.

If we look at `Notation.lean`, we see the precedence levels of various
notations.

```
@[inherit_doc] infixr:90 " ∘ "  => Function.comp
@[inherit_doc] infixr:35 " × "  => Prod
@[inherit_doc] infixr:35 " ×' " => PProd
@[inherit_doc]  infix:50 " ∣ " => Dvd.dvd
@[inherit_doc] infixl:55 " ||| " => HOr.hOr
@[inherit_doc] infixl:58 " ^^^ " => HXor.hXor
@[inherit_doc] infixl:60 " &&& " => HAnd.hAnd
@[inherit_doc] infixl:65 " + "   => HAdd.hAdd
@[inherit_doc] infixl:65 " - "   => HSub.hSub
@[inherit_doc] infixl:70 " * "   => HMul.hMul
@[inherit_doc] infixl:70 " / "   => HDiv.hDiv
@[inherit_doc] infixl:70 " % "   => HMod.hMod
@[inherit_doc] infixl:75 " <<< " => HShiftLeft.hShiftLeft
@[inherit_doc] infixl:75 " >>> " => HShiftRight.hShiftRight
@[inherit_doc] infixr:80 " ^ "   => HPow.hPow
@[inherit_doc] infixl:65 " ++ "  => HAppend.hAppend
@[inherit_doc] prefix:75 "-"     => Neg.neg
@[inherit_doc] prefix:100 "~~~"  => Complement.complement
@[inherit_doc] postfix:max "⁻¹"  => Inv.inv
@[inherit_doc] infixr:73 " • " => HSMul.hSMul
```

If we take further into account that the precedence of the
arrow `→` is `25`, then my earlier choice of `40` makes it
weaker than all other usual operators, but still stronger than
implication, which is roughly where I wanted to place it.
One actually cannot make the definition of `NSteps` use `Iterate`
because `Step` is a tagged relation, and `Iterate` does not
support merging the observations between `Step`s.
Actually, we can see `List Obs` to be the free monoid of `Obs`, so
we don't actually gain any expressivity by changing the definition.
Maybe it would make for a nicer API, but it doesn't warrant making
the change at this stage.
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.

2 participants