Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
858c1fd
upload
markusdemedeiros Jun 16, 2026
1a11681
more golf
markusdemedeiros Jun 16, 2026
65d12bd
remove stale aliases
markusdemedeiros Jun 16, 2026
100afe7
solve SubredexesAreValues via local macro
markusdemedeiros Jun 18, 2026
d308de0
copy files from completeness branch
markusdemedeiros Jun 18, 2026
52ff194
Merge branch 'master' into completeness-infra
markusdemedeiros Jun 19, 2026
618c58f
Merge branch 'master' into completeness-infra
markusdemedeiros Jun 22, 2026
08c15ac
fix build
markusdemedeiros Jun 22, 2026
abc786d
chore: tidy frac
markusdemedeiros Jun 22, 2026
fcd6037
chore: cleanup bigsepmap
markusdemedeiros Jun 22, 2026
ea98f88
chore: cleanup Fractional
markusdemedeiros Jun 22, 2026
ba317fb
chore: cleanup PartialMap
markusdemedeiros Jun 22, 2026
de423d2
upload changes from completeness
markusdemedeiros Jun 18, 2026
35d6c43
checkpoint
markusdemedeiros Jun 23, 2026
959ea03
Merge branch 'master' into completeness-primitivelaws
markusdemedeiros Jun 24, 2026
917c49a
Merge branch 'master' into completeness-primitivelaws
markusdemedeiros Jul 1, 2026
c7eb1c4
fix outdated comments
markusdemedeiros Jul 1, 2026
0388296
cleanup
markusdemedeiros Jul 1, 2026
fc36365
upload files from completeness branch
markusdemedeiros Jun 18, 2026
7df3c66
fix build
markusdemedeiros Jul 1, 2026
e1980b7
Merge branch 'master' into completeness-abstractwp
markusdemedeiros Jul 6, 2026
e3c4ee1
minor changes
markusdemedeiros Jul 6, 2026
0994d0e
upload
markusdemedeiros Jun 18, 2026
77560c3
fix build
markusdemedeiros Jul 7, 2026
5cc7d43
pass
markusdemedeiros Jul 8, 2026
f55e95d
Merge branch 'master' into completeness-main-theorem
markusdemedeiros Jul 10, 2026
75886fe
desloppify comments
markusdemedeiros Jul 10, 2026
6689831
minor
markusdemedeiros Jul 10, 2026
1c2f181
minor
markusdemedeiros Jul 12, 2026
18443e4
Merge branch 'master' into completeness-main-theorem
markusdemedeiros Jul 15, 2026
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
148 changes: 148 additions & 0 deletions Iris/Iris/ProgramLogic/AbstractEctxLangCompleteness.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/-
Copyright (c) 2026 Markus de Medeiros. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
-/
module

public import Iris.Algebra
public import Iris.BI
public import Iris.ProofMode
public import Iris.ProgramLogic.Language
public import Iris.ProgramLogic.EctxLanguage
public import Iris.ProgramLogic.Adequacy
public import Iris.ProgramLogic.ThreadPool
public import Iris.ProgramLogic.AbstractWeakestPre
public import Iris.ProgramLogic.AbstractLangCompleteness
public import Iris.Instances.Lib.Invariants
public import Iris.Instances.Lib.CInvariants
public import Iris.Instances.Lib.GhostMap
public import Iris.Std.FromMathlib

namespace Iris.ProgramLogic

open Iris Iris.BI Iris.Algebra Std FromMathlib
open Iris.ProgramLogic.PrimStep
open Language Language.Notation

@[expose] public section

section AbstractEctxCompleteness

variable {Expr State Obs Val Ectx : Type _}
variable [EctxLanguage Expr Ectx State Obs Val]
variable {GF : BundledGFunctors} {HLC : HasLC} [IrisGS_gen HLC Expr GF]
variable {H : Type _ → Type _} [LawfulFiniteMap H Nat]
variable [TI : TpinvGS GF Expr H]

public def ectxLangCompletenessStmt (wp : AbstractWP Expr Val GF)
(heap_inv : List Expr → State → IProp GF) (n : Nat) (C : List Expr) (e₁ : Expr) (σ : State)
(K : Ectx) (E : CoPset) : IProp GF := iprop%
⌜BaseStep.Reducible (e₁, σ)⌝ -∗
(n ↪thread (EvContext.fill K e₁)) -∗
heap_inv C σ ∗ tpInv C ∗ ⌜cfgSafe (C, σ)⌝ ={E}=∗
((⌜Atomic .WeaklyAtomic e₁⌝ ∗
(∀ Φ,
(▷ ∀ κ v₂ σ' efs,
⌜PrimStep.primStep (e₁, σ) κ (ToVal.ofVal v₂, σ', efs)⌝ -∗
isThread n (.own 1) (EvContext.fill K e₁) -∗
tpInv C ==∗
(heap_inv ((C.set n (EvContext.fill K (ToVal.ofVal v₂))) ++ efs) σ' -∗ Φ v₂) ∗
[∗list] _i ↦ etp ∈ efs, wp ⊤ etp (fun (_ : Val) => iprop(True))) -∗
wp E e₁ Φ))
(heap_inv C σ ∗ tpInv C ∗ ∀ Ψ,
(▷ ∀ e₂ efs,
(∀ σ₁ C₁,
heap_inv C₁ σ₁ ∗ tpInv C₁ ∗ ⌜cfgSafe (C₁, σ₁)⌝ ={E}=∗
∃ κ σ₁',
⌜PrimSteps e₁ σ₁ κ e₂ σ₁' efs⌝ ∗
isThread n (.own 1) (EvContext.fill K e₁) ∗
tpInv C₁ ∗
heap_inv ((C₁.set n (EvContext.fill K e₂)) ++ efs) σ₁') ={⊤}=∗
wp ⊤ e₂ Ψ ∗
([∗list] _j ↦ etp ∈ efs, wp ⊤ etp (fun (_ : Val) => iprop(True)))) -∗
wp ⊤ e₁ Ψ))

public class AbstractEctxLangCompletenessGen
(wp : AbstractWP Expr Val GF) [BindAbstractWP wp] where
heap_inv : List Expr → State → IProp GF
heap_inv_timeless (C : List Expr) (σ : State) : Timeless (heap_inv C σ)
ectx_lang_completeness (n : Nat) (C : List Expr) (e₁ : Expr) (σ : State) (K : Ectx) (E : CoPset) :
⊢ ectxLangCompletenessStmt wp heap_inv n C e₁ σ K E

attribute [instance] AbstractEctxLangCompletenessGen.heap_inv_timeless

end AbstractEctxCompleteness

/-! ### Lifting the ectx-level soundness equation to the prim level. -/

section Lifting

variable {Expr State Obs Val Ectx : Type _}
variable [EctxLanguage Expr Ectx State Obs Val]
variable {GF : BundledGFunctors} {HLC : HasLC} [IrisGS_gen HLC Expr GF]
variable {H : Type _ → Type _} [LawfulFiniteMap H Nat]
variable [TI : TpinvGS GF Expr H]
variable {wp : AbstractWP Expr Val GF}
variable [BWP : BindAbstractWP wp]
variable [AEC : AbstractEctxLangCompletenessGen wp]

theorem weakestpre_ectx_to_prim_completeness (n : Nat) (C : List Expr) (e₁ : Expr)
(σ : State) (E : CoPset) :
⊢ abstractECTXLangComplete (TI := TI) wp AEC.heap_inv n C e₁ σ E := by
iintro %Hred Htok ⟨Hheap, Htp, %Hsafe⟩
obtain ⟨κ, e', σ', efs, hstep⟩ := Hred
obtain @⟨e₁', e₂', K, Hbase⟩ := hstep
have Hbred : BaseStep.Reducible (e₁', σ) := ⟨κ, e₂', σ', efs, Hbase⟩
have key := AEC.ectx_lang_completeness n C e₁' σ K E
unfold ectxLangCompletenessStmt at key
imod key $$ %Hbred Htok [Hheap Htp] with (⟨%Hatom, HH⟩ | ⟨Hheap, Htp, HH⟩)
· iframe Hheap Htp %Hsafe
· clear key
imodintro
ileft
iexists (fill (Expr := Expr) K), e₁'
have Hctx : Context (fill (Expr := Expr) K) := inferInstance
have Heq : fill (Expr := Expr) K e₁' = fill (Expr := Expr) K e₁' := rfl
have Hnv : ToVal.toVal e₁' = none := EctxLanguage.val_stuck Hbase
iframe %Hctx %Heq %Hnv %Hatom
iintro %Ψ Hpre
iapply HH $$ Hpre
· clear key
imodintro
iright
iframe Hheap Htp
iintro %Ψ Hc
iapply (BWP.wp_bind (K := fill (Expr := Expr) K) (e := e₁') (Φ := Ψ)).1
iapply HH
inext
iintro %e₂ %efs H
ihave Hprem : iprop(∀ σ₁ C₁,
AEC.heap_inv C₁ σ₁ ∗ tpInv C₁ ∗ ⌜cfgSafe (C₁, σ₁)⌝ ={E}=∗
∃ κ σ₁', ⌜PrimSteps (fill (Expr := Expr) K e₁') σ₁ κ (fill (Expr := Expr) K e₂) σ₁' efs⌝ ∗
(n ↪thread fill (Expr := Expr) K e₁') ∗ tpInv C₁ ∗
AEC.heap_inv (C₁.set n (fill (Expr := Expr) K e₂) ++ efs) σ₁') $$ [H]
· iintro %σ₁ %C₁ ⟨Hi, Htp1, %Hs⟩
imod H $$ [Hi Htp1] with ⟨%κ', %σ₁', %Hps, Htok2, Htp1', Hhp⟩
· iframe Hi Htp1 %Hs
imodintro
iexists κ', σ₁'
iframe Htok2 Htp1' Hhp
ipureintro
exact Hps.fill
imod Hc $$ Hprem with ⟨Hwp, Hlist⟩
imodintro
iframe
iapply (BWP.wp_bind (K := fill (Expr := Expr) K) (e := e₂) (Φ := Ψ)).2 $$ Hwp

instance abstract_ectx_to_completeness :
AbstractLangCompletenessGen wp where
heap_inv := AEC.heap_inv
heap_inv_timeless := AEC.heap_inv_timeless
lang_completeness {n C e₁ σ E} := weakestpre_ectx_to_prim_completeness n C e₁ σ E

end Lifting

end

end Iris.ProgramLogic
Loading