Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Iris/Iris/BI/WeakestPre.lean
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ instance : Std.IsPreorder Stuckness where

end Stuckness

class Wp (PROP Expr : Type _) (Val : outParam (Type _)) (A : Type _) where
class Wp (PROP Expr : Type _) (Val : outParam (Type _)) (A : outParam (Type _)) where
wp : A → CoPset → Expr → (Val → PROP) → PROP

class TotalWP (PROP Expr) (Val : outParam (Type _)) (A : Type _) where
class TotalWp (PROP Expr) (Val : outParam (Type _)) (A : outParam (Type _)) where
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The reason why there was a Wp and TotalWP is that, per Iris conventions and Mathlibs naming conventions, both should be spelled out as WP. However, this makes the WP e @ s {{ Q }} notation clash with the typeclass name, which is why I changed it to Wp while I was developing on the file. I think we may be able to fix this by making "WP wpExpr wpPostcond" atomic, so if it cannot be parsed as such it chooses to parse WP as an identifier instead. However, I'm not sure what other ramifications making the whole parser atomic could unchain.

I just wanted to point this out in case we wanted to make the deliberate decision to deviate from normal naming conventions in order to dodge this issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I couldn't find a way to fix it with atomic or something of the sort. I guess this is why Std.Do defines its notation for WP wrapping on the program instead, as wp⟦$x:term⟧ $Q

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing this out! It seems like you thought about this quite a bit more than I did. I just thought that TotalWP is a typo since TotalWP and Wp seems inconsistent. (I don't know the mathlib naming convention well enough to say whether WP or Wp is the right spelling, both seems fine to me.) @markusdemedeiros What are your thoughts about this?

totalWp : A → CoPset → Expr → (Val → PROP) → PROP

syntax wpExpr :=
Expand Down Expand Up @@ -109,7 +109,7 @@ meta def wpMacro : Lean.Macro := fun stx => do
let (e, s, E) ← parseWpExpr expr
let (Φ, useTotal?) ← parseWpPostcond postcond
if useTotal? then
`(TotalWP.totalWp $s $E $e $Φ)
`(TotalWp.totalWp $s $E $e $Φ)
else
`(Wp.wp $s $E $e $Φ)
| _ => Lean.Macro.throwUnsupported
Expand Down Expand Up @@ -137,7 +137,7 @@ meta def unexpanderWp : PrettyPrinter.Unexpander
`(WP $wpExpr {{ $wpPostcondInner }})
| _ => throw ()

@[app_unexpander TotalWP.totalWp]
@[app_unexpander TotalWp.totalWp]
meta def unexpanderTotalWp : PrettyPrinter.Unexpander
| `($_wp $s $E $e $Φ) => do
let wpExpr ← makeWpExpr s E e
Expand Down
8 changes: 3 additions & 5 deletions Iris/Iris/Tests/WP.lean
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ open Iris
section TestWP
set_option linter.unusedVariables false

variable (PROP Expr : Type _) (Val : outParam (Type _)) (A : Type _)
variable [Wp PROP Expr Val A]
variable (PROP Expr : Type _) (Val : Type _)
variable [Wp PROP Expr Val Stuckness]
variable [TotalWP PROP Expr Val A]
variable [TotalWP PROP Expr Val Stuckness]
variable [TotalWp PROP Expr Val Stuckness]

variable (e : Expr) (s : A) (E : CoPset)
variable (e : Expr) (s : Stuckness) (E : CoPset)

-- Base no-binder cases
variable (Φ : Val → PROP)
Expand Down