Skip to content

Instantly share code, notes, and snippets.

@kory33
Last active December 13, 2025 16:04
Show Gist options
  • Select an option

  • Save kory33/c9ec5f858048dd448e7e83cb08662651 to your computer and use it in GitHub Desktop.

Select an option

Save kory33/c9ec5f858048dd448e7e83cb08662651 to your computer and use it in GitHub Desktop.
-- Adapted encodings from https://dl.acm.org/doi/pdf/10.1145/3571255
structure EffectSet (AbstractState : Type) : Type 1 where
Ops : (precondition : AbstractState → Prop) → Type
Ret : (precondition : AbstractState → Prop) → Ops precondition → Type
Transition : (precondition : AbstractState → Prop) → Ops precondition → (AbstractState → Prop)
inductive HoareFreer (AbstractState : Type) (es : EffectSet AbstractState) :
(precondition : AbstractState → Prop) → (postcondition : AbstractState → Prop) → (result : Type) → Type 1 where
| End : {result : Type} → {condition : AbstractState → Prop} →
(res : result) → HoareFreer AbstractState es condition condition result
| RunAndThen : {pre post : AbstractState → Prop} →
(instr : es.Ops pre) →
(continuation : es.Ret pre instr → HoareFreer AbstractState es (es.Transition pre instr) post result) →
HoareFreer AbstractState es pre post result
inductive GetSetOps (S : Type) where
| Get
| Set : S → GetSetOps S
def HoareGetSet (S : Type) : EffectSet S :=
{ Ops := Function.const _ (GetSetOps S),
Ret := fun pre => (fun
| .Get => { s : S // pre s }
| .Set _ => Unit
),
Transition := fun pre => (fun
| .Get => pre
| .Set operand => fun s => s = operand
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment