Fil-C on Nix

Filnix wiki

the formal campaign

rocq/theories/HelloLocale.v

GNU Hello's locale helpers through the program logic of Logic.v (docs/logic.md): gnulib's hard_locale and the setlocale_null_r chain beneath it, which rpl_mbrtowc calls to decide whether a byte may stand for itself.

setlocale_null_unlocked(k) is setlocale's query of the category k, whose answer is libc's own name for it: a string the world lends (LentLogic.v). setlocale_null_r_unlocked(k, buf, n) copies that name into buf when it fits, returning 0, or the n - 1 bytes that do with a NUL after them, returning ERANGE (34); a name is never NULL, so the EINVAL path (22) is dead. hard_locale(k) copies the name into a 257-byte local and compares it with "C" and "POSIX".

The triples are generic in the world interpretation wi, given that wi keeps every lent string where lent_at says, that setlocale's query answers with the lent pointer and changes nothing, and that wi survives the allocation, the copy and the byte store these functions make into memory they own.

From iris.proofmode Require Import proofmode
From iris.base_logic.lib Require Import gen_heap
From iris.program_logic Require Import language weakestpre
From Stdlib Require Import ZArith Lia
From Stdlib Require String
From Nanofil Require Import Term Syntax Values Memory Runtime Ops Semantics Run StepRules Symbolic ExternalCalls ExternalMachine Pieces Heap ContractFrame Language Logic StringLogic MemLogic LentLogic HelloModule HelloLeaf
Open Scope Z_scope
Open Scope list_scope
Arguments Z.add : simpl nomatch
Arguments Z.sub : simpl nomatch
Arguments Z.mul : simpl nomatch

Integer arithmetic on an unknown stays folded when a premise is computed.

The functions

setlocale_null_unlocked(category).

40Definition snu_fn: func ≔
Eval vm_compute in hello_fn"setlocale_null_unlocked"

Its one block: setlocale's query, returned.

42Definition u_start: block ≔
Eval vm_compute in hblksnu_fn "start"

setlocale_null_r_unlocked(category, buf, bufsize).

45Definition snru_fn: func ≔
Eval vm_compute in hello_fn"setlocale_null_r_unlocked"

Query the name; is it NULL?

47Definition r_start: block ≔
Eval vm_compute in hblksnru_fn "start"

Its length; does it fit?

49Definition r_L10: block ≔
Eval vm_compute in hblksnru_fn "L10"

It fits: copy it with its NUL, and return 0.

51Definition r_L27: block ≔
Eval vm_compute in hblksnru_fn "L27"

It does not: is there room for anything?

53Definition r_L28: block ≔
Eval vm_compute in hblksnru_fn "L28"

Copy what fits, and end it with a NUL.

55Definition r_L39: block ≔
Eval vm_compute in hblksnru_fn "L39"

Return ERANGE.

57Definition r_L41: block ≔
Eval vm_compute in hblksnru_fn "L41"

setlocale_null_r(category, buf, bufsize), without a lock.

60Definition snr_fn: func ≔
Eval vm_compute in hello_fn"setlocale_null_r"

Its one block: the unlocked call, returned.

62Definition n_start: block ≔
Eval vm_compute in hblksnr_fn "start"

hard_locale(category).

65Definition hard_locale_fn: func ≔
Eval vm_compute in hello_fn"hard_locale"

A 257-byte buffer, and the name into it.

67Definition h_start: block ≔
Eval vm_compute in hblkhard_locale_fn "start"

The name did not fit: not a hard locale.

69Definition h_L3: block ≔
Eval vm_compute in hblkhard_locale_fn "L3"

Is it "C"?

71Definition h_L5: block ≔
Eval vm_compute in hblkhard_locale_fn "L5"

Is it "POSIX"?

73Definition h_L16: block ≔
Eval vm_compute in hblkhard_locale_fn "L16"

Branch on the answer.

75Definition h_L17: block ≔
Eval vm_compute in hblkhard_locale_fn "L17"

A hard locale.

77Definition h_L10: block ≔
Eval vm_compute in hblkhard_locale_fn "L10"

"C" or "POSIX": not a hard locale.

79Definition h_L12: block ≔
Eval vm_compute in hblkhard_locale_fn "L12"

setlocale_null_unlocked has its entry.

82Lemma find_u_start
Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v4" P GlobalTAtom"setlocale" ArgW TmpTAtom"v0"; ArgP Const0; b_jump ≔ JRetTmpTAtom"v4" = Someb_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v4" P GlobalTAtom"setlocale" ArgW TmpTAtom"v0"; ArgP Const0; b_jump ≔ JRetTmpTAtom"v4"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

setlocale_null_r_unlocked has its entry.

85Lemma find_r_start
Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v8" P GlobalTAtom"setlocale_null_unlocked" ArgW TmpTAtom"v0"; LetTAtom"v13" L Ptoi TmpTAtom"v8"; LetTAtom"v14" L Ptoi Const0; LetTAtom"v15" W CmpEq L TmpTAtom"v13"; TmpTAtom"v14"; b_jump ≔ JBranchTmpTAtom"v15" ToTAtom"L9" ToTAtom"L10" = Someb_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v8" P GlobalTAtom"setlocale_null_unlocked" ArgW TmpTAtom"v0"; LetTAtom"v13" L Ptoi TmpTAtom"v8"; LetTAtom"v14" L Ptoi Const0; LetTAtom"v15" W CmpEq L TmpTAtom"v13"; TmpTAtom"v14"; b_jump ≔ JBranchTmpTAtom"v15" ToTAtom"L9" ToTAtom"L10"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

setlocale_null_r_unlocked has L10.

88Lemma find_r_L10
Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L10"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v26" L GlobalTAtom"strlen" ArgP TmpTAtom"v8"; LetTAtom"v32" W CmpUlt L TmpTAtom"v26"; TmpTAtom"v4"; b_jump ≔ JBranchTmpTAtom"v32" ToTAtom"L27" ToTAtom"L28" = Someb_label ≔ TAtom"L10"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v26" L GlobalTAtom"strlen" ArgP TmpTAtom"v8"; LetTAtom"v32" W CmpUlt L TmpTAtom"v26"; TmpTAtom"v4"; b_jump ≔ JBranchTmpTAtom"v32" ToTAtom"L27" ToTAtom"L28"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

setlocale_null_r_unlocked has L27.

91Lemma find_r_L27
Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L27"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v36" L Add TmpTAtom"v26"; Const1; CallCResultTAtom"v37" P GlobalTAtom"memcpy" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v8"; ArgL TmpTAtom"v36"; b_jump ≔ JRetConst0 = Someb_label ≔ TAtom"L27"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v36" L Add TmpTAtom"v26"; Const1; CallCResultTAtom"v37" P GlobalTAtom"memcpy" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v8"; ArgL TmpTAtom"v36"; b_jump ≔ JRetConst0

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

setlocale_null_r_unlocked has L28.

94Lemma find_r_L28
Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L28"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v43" W CmpUgt L TmpTAtom"v4"; Const0; b_jump ≔ JBranchTmpTAtom"v43" ToTAtom"L39" ToTAtom"L41" = Someb_label ≔ TAtom"L28"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v43" W CmpUgt L TmpTAtom"v4"; Const0; b_jump ≔ JBranchTmpTAtom"v43" ToTAtom"L39" ToTAtom"L41"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

setlocale_null_r_unlocked has L39.

97Lemma find_r_L39
Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L39"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v47" L Sub TmpTAtom"v4"; Const1; CallCResultTAtom"v48" P GlobalTAtom"memcpy" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v8"; ArgL TmpTAtom"v47"; FlightTAtom"v52" Add FAddressTmpTAtom"v2"; FValueTmpTAtom"v47" LowerOfTmpTAtom"v2"; LetTAtom"chk1" A Check0 1 Write 1 TmpTAtom"v52"; RawStoreWb 0 Const0 TmpTAtom"chk1"; b_jump ≔ JGotoToTAtom"L41" = Someb_label ≔ TAtom"L39"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v47" L Sub TmpTAtom"v4"; Const1; CallCResultTAtom"v48" P GlobalTAtom"memcpy" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v8"; ArgL TmpTAtom"v47"; FlightTAtom"v52" Add FAddressTmpTAtom"v2"; FValueTmpTAtom"v47" LowerOfTmpTAtom"v2"; LetTAtom"chk1" A Check0 1 Write 1 TmpTAtom"v52"; RawStoreWb 0 Const0 TmpTAtom"chk1"; b_jump ≔ JGotoToTAtom"L41"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

setlocale_null_r_unlocked has L41.

100Lemma find_r_L41
Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L41"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst34 = Someb_label ≔ TAtom"L41"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst34

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

setlocale_null_r has its entry.

103Lemma find_n_start
Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v9" W GlobalTAtom"setlocale_null_r_unlocked" ArgW TmpTAtom"v0"; ArgP TmpTAtom"v2"; ArgL TmpTAtom"v4"; b_jump ≔ JRetTmpTAtom"v9" = Someb_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v9" W GlobalTAtom"setlocale_null_r_unlocked" ArgW TmpTAtom"v0"; ArgP TmpTAtom"v2"; ArgL TmpTAtom"v4"; b_jump ≔ JRetTmpTAtom"v9"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

hard_locale has its entry.

106Lemma find_h_start
Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v2" P Alloc4 Const257; CallCResultTAtom"v7" W GlobalTAtom"setlocale_null_r" ArgW TmpTAtom"v0"; ArgP TmpTAtom"v2"; ArgL Const257; b_jump ≔ JBranchTmpTAtom"v7" ToTAtom"L3" ToTAtom"L5" = Someb_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v2" P Alloc4 Const257; CallCResultTAtom"v7" W GlobalTAtom"setlocale_null_r" ArgW TmpTAtom"v0"; ArgP TmpTAtom"v2"; ArgL Const257; b_jump ≔ JBranchTmpTAtom"v7" ToTAtom"L3" ToTAtom"L5"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

hard_locale has L3.

Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L3"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst0 = Someb_label ≔ TAtom"L3"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst0

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

hard_locale has L5.

Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L5"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v13" P Copy GlobalTAtom"hard-locale#str.31"; CallCResultTAtom"v14" W GlobalTAtom"streq" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v13"; LetTAtom"v15" W ExtUb TmpTAtom"v14"; b_jump ≔ JBranchTmpTAtom"v15" ToTAtom"L17" ToTAtom"L16" = Someb_label ≔ TAtom"L5"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v13" P Copy GlobalTAtom"hard-locale#str.31"; CallCResultTAtom"v14" W GlobalTAtom"streq" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v13"; LetTAtom"v15" W ExtUb TmpTAtom"v14"; b_jump ≔ JBranchTmpTAtom"v15" ToTAtom"L17" ToTAtom"L16"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

hard_locale has L16.

Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L16"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v18" P Copy GlobalTAtom"hard-locale#str.32"; CallCResultTAtom"v19" W GlobalTAtom"streq" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v18"; LetTAtom"v20" W ExtUb TmpTAtom"v19"; LetTAtom"v21" W CmpNe W TmpTAtom"v20"; Const0; b_jump ≔ JGotoToTAtom"L17" = Someb_label ≔ TAtom"L16"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v18" P Copy GlobalTAtom"hard-locale#str.32"; CallCResultTAtom"v19" W GlobalTAtom"streq" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v18"; LetTAtom"v20" W ExtUb TmpTAtom"v19"; LetTAtom"v21" W CmpNe W TmpTAtom"v20"; Const0; b_jump ≔ JGotoToTAtom"L17"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

hard_locale has L17.

Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L17"; b_phis ≔ PhiTAtom"v22" W TAtom"L5", Const1; TAtom"L16", TmpTAtom"v21"; b_insts ≔ [ ]; b_jump ≔ JBranchTmpTAtom"v22" ToTAtom"L12" ToTAtom"L10" = Someb_label ≔ TAtom"L17"; b_phis ≔ PhiTAtom"v22" W TAtom"L5", Const1; TAtom"L16", TmpTAtom"v21"; b_insts ≔ [ ]; b_jump ≔ JBranchTmpTAtom"v22" ToTAtom"L12" ToTAtom"L10"

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

hard_locale has L10.

Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L10"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst1 = Someb_label ≔ TAtom"L10"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst1

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

hard_locale has L12.

Explore proof 2 tactics

Initial goal

vm_compute

⊢
Someb_label ≔ TAtom"L12"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst0 = Someb_label ≔ TAtom"L12"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst0

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
reflexivity

setlocale_null_unlocked's entry binds its category.

128Lemma snu_entry
∀ k
invocationsnu_fn WIntk = mkFramesnu_fn TAtom"v0", WIntk [ ] None EnterTAtom"start" None
Explore proof 1 tactics

Initial goal

k :
Z
⊢
invocationsnu_fn WIntk = fr_fn ≔ snu_fn; fr_env ≔ TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"start" None

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
reflexivity

setlocale_null_r_unlocked's entry binds its category, buffer and size.

132Lemma snru_entry
∀ k p n
invocationsnru_fn WIntk; WPtrp; WIntn = mkFramesnru_fn TAtom"v4", WIntn; TAtom"v2", WPtrp; TAtom"v0", WIntk [ ] None EnterTAtom"start" None
Explore proof 1 tactics

Initial goal

k :
Z
p :
n :
Z
⊢
invocationsnru_fn WIntk; WPtrp; WIntn = fr_fn ≔ snru_fn; fr_env ≔ TAtom"v4", WIntn; TAtom"v2", WPtrp; TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"start" None

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
reflexivity

setlocale_null_r's entry binds its category, buffer and size.

138Lemma snr_entry
∀ k p n
invocationsnr_fn WIntk; WPtrp; WIntn = mkFramesnr_fn TAtom"v4", WIntn; TAtom"v2", WPtrp; TAtom"v0", WIntk [ ] None EnterTAtom"start" None
Explore proof 1 tactics

Initial goal

k :
Z
p :
n :
Z
⊢
invocationsnr_fn WIntk; WPtrp; WIntn = fr_fn ≔ snr_fn; fr_env ≔ TAtom"v4", WIntn; TAtom"v2", WPtrp; TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"start" None

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
reflexivity

hard_locale's entry binds its category.

144Lemma hard_locale_entry
Explore proof 1 tactics

Initial goal

k :
Z
⊢
invocationhard_locale_fn WIntk = fr_fn ≔ hard_locale_fn; fr_env ≔ TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"start" None

reflexivity

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
reflexivity

The genv's functions, for a genv with Hello's module.

150Lemma locale_fns
∀ ge
find_fnge TAtom"setlocale_null_unlocked" = SomeDefinedsnu_fn ∧ find_fnge TAtom"setlocale_null_r_unlocked" = SomeDefinedsnru_fn ∧ find_fnge TAtom"setlocale_null_r" = SomeDefinedsnr_fn
Explore proof 5 tactics

Initial goal

ge :
⊢
ge_modulege = hello_module → find_fnge TAtom"setlocale_null_unlocked" = SomeDefinedsnu_fn ∧ find_fnge TAtom"setlocale_null_r_unlocked" = SomeDefinedsnru_fn ∧ find_fnge TAtom"setlocale_null_r" = SomeDefinedsnr_fn

intros Hm

⊢
find_fnge TAtom"setlocale_null_unlocked" = SomeDefinedsnu_fn ∧ find_fnge TAtom"setlocale_null_r_unlocked" = SomeDefinedsnru_fn ∧ find_fnge TAtom"setlocale_null_r" = SomeDefinedsnr_fn

unfold find_fn

⊢
match find_directTAtom"setlocale_null_unlocked" ge_modulege with
Somed
⇒
Somed
None
⇒
let* t ≔ find_aliasTAtom"setlocale_null_unlocked" ge_modulege in
=
∧
match find_directTAtom"setlocale_null_r_unlocked" ge_modulege with
Somed
⇒
Somed
None
⇒
let* t ≔ find_aliasTAtom"setlocale_null_r_unlocked" ge_modulege in
=
∧
match find_directTAtom"setlocale_null_r" ge_modulege with
Somed
⇒
Somed
None
⇒
let* t ≔ find_aliasTAtom"setlocale_null_r" ge_modulege in
=

rewrite Hm

⊢
match find_directTAtom"setlocale_null_unlocked" hello_module with
Somed
⇒
Somed
None
⇒
let* t ≔ find_aliasTAtom"setlocale_null_unlocked" hello_module in
=
∧
match find_directTAtom"setlocale_null_r_unlocked" hello_module with
Somed
⇒
Somed
None
⇒
let* t ≔ find_aliasTAtom"setlocale_null_r_unlocked" hello_module in
=
∧
match find_directTAtom"setlocale_null_r" hello_module with
Somed
⇒
Somed
None
⇒
let* t ≔ find_aliasTAtom"setlocale_null_r" hello_module in
=

vm_compute

⊢
SomeDefinedfn_name ≔ TAtom"setlocale_null_unlocked"; fn_linkage ≔ TAtom"export"; fn_ret ≔ RClassP; fn_params ≔ W, TAtom"v0"; fn_blocks ≔ b_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v4" P GlobalTAtom"setlocale" ArgW TmpTAtom"v0"; ArgP Const0; b_jump ≔ JRetTmpTAtom"v4" = SomeDefinedfn_name ≔ TAtom"setlocale_null_unlocked"; fn_linkage ≔ TAtom"export"; fn_ret ≔ RClassP; fn_params ≔ W, TAtom"v0"; fn_blocks ≔ b_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v4" P GlobalTAtom"setlocale" ArgW TmpTAtom"v0"; ArgP Const0; b_jump ≔ JRetTmpTAtom"v4" ∧ SomeDefinedfn_name ≔ TAtom"setlocale_null_r_unlocked"; fn_linkage ≔ TAtom"export"; fn_ret ≔ RClassW; fn_params ≔ W, TAtom"v0"; P, TAtom"v2"; L, TAtom"v4"; fn_blocks ≔ b_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v8" P GlobalTAtom"setlocale_null_unlocked" ArgW TmpTAtom"v0"; LetTAtom"v13" L Ptoi TmpTAtom"v8"; LetTAtom"v14" L Ptoi Const0; LetTAtom"v15" W CmpEq L TmpTAtom"v13"; TmpTAtom"v14"; b_jump ≔ JBranchTmpTAtom"v15" ToTAtom"L9" ToTAtom"L10"; b_label ≔ TAtom"L9"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v20" W CmpUgt L TmpTAtom"v4"; Const0; b_jump ≔ JBranchTmpTAtom"v20" ToTAtom"L16" ToTAtom"L18"; b_label ≔ TAtom"L16"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"chk0" A Check0 1 Write 1 TmpTAtom"v2"; RawStoreWb 0 Const0 TmpTAtom"chk0"; b_jump ≔ JGotoToTAtom"L18"; b_label ≔ TAtom"L18"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst22; b_label ≔ TAtom"L10"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v26" L GlobalTAtom"strlen" ArgP TmpTAtom"v8"; LetTAtom"v32" W CmpUlt L TmpTAtom"v26"; TmpTAtom"v4"; b_jump ≔ JBranchTmpTAtom"v32" ToTAtom"L27" ToTAtom"L28"; b_label ≔ TAtom"L27"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v36" L Add TmpTAtom"v26"; Const1; CallCResultTAtom"v37" P GlobalTAtom"memcpy" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v8"; ArgL TmpTAtom"v36"; b_jump ≔ JRetConst0; b_label ≔ TAtom"L28"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v43" W CmpUgt L TmpTAtom"v4"; Const0; b_jump ≔ JBranchTmpTAtom"v43" ToTAtom"L39" ToTAtom"L41"; b_label ≔ TAtom"L39"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v47" L Sub TmpTAtom"v4"; Const1; CallCResultTAtom"v48" P GlobalTAtom"memcpy" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v8"; ArgL TmpTAtom"v47"; FlightTAtom"v52" Add FAddressTmpTAtom"v2"; FValueTmpTAtom"v47" LowerOfTmpTAtom"v2"; LetTAtom"chk1" A Check0 1 Write 1 TmpTAtom"v52"; RawStoreWb 0 Const0 TmpTAtom"chk1"; b_jump ≔ JGotoToTAtom"L41"; b_label ≔ TAtom"L41"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst34 = SomeDefinedfn_name ≔ TAtom"setlocale_null_r_unlocked"; fn_linkage ≔ TAtom"export"; fn_ret ≔ RClassW; fn_params ≔ W, TAtom"v0"; P, TAtom"v2"; L, TAtom"v4"; fn_blocks ≔ b_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v8" P GlobalTAtom"setlocale_null_unlocked" ArgW TmpTAtom"v0"; LetTAtom"v13" L Ptoi TmpTAtom"v8"; LetTAtom"v14" L Ptoi Const0; LetTAtom"v15" W CmpEq L TmpTAtom"v13"; TmpTAtom"v14"; b_jump ≔ JBranchTmpTAtom"v15" ToTAtom"L9" ToTAtom"L10"; b_label ≔ TAtom"L9"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v20" W CmpUgt L TmpTAtom"v4"; Const0; b_jump ≔ JBranchTmpTAtom"v20" ToTAtom"L16" ToTAtom"L18"; b_label ≔ TAtom"L16"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"chk0" A Check0 1 Write 1 TmpTAtom"v2"; RawStoreWb 0 Const0 TmpTAtom"chk0"; b_jump ≔ JGotoToTAtom"L18"; b_label ≔ TAtom"L18"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst22; b_label ≔ TAtom"L10"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v26" L GlobalTAtom"strlen" ArgP TmpTAtom"v8"; LetTAtom"v32" W CmpUlt L TmpTAtom"v26"; TmpTAtom"v4"; b_jump ≔ JBranchTmpTAtom"v32" ToTAtom"L27" ToTAtom"L28"; b_label ≔ TAtom"L27"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v36" L Add TmpTAtom"v26"; Const1; CallCResultTAtom"v37" P GlobalTAtom"memcpy" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v8"; ArgL TmpTAtom"v36"; b_jump ≔ JRetConst0; b_label ≔ TAtom"L28"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v43" W CmpUgt L TmpTAtom"v4"; Const0; b_jump ≔ JBranchTmpTAtom"v43" ToTAtom"L39" ToTAtom"L41"; b_label ≔ TAtom"L39"; b_phis ≔ [ ]; b_insts ≔ LetTAtom"v47" L Sub TmpTAtom"v4"; Const1; CallCResultTAtom"v48" P GlobalTAtom"memcpy" ArgP TmpTAtom"v2"; ArgP TmpTAtom"v8"; ArgL TmpTAtom"v47"; FlightTAtom"v52" Add FAddressTmpTAtom"v2"; FValueTmpTAtom"v47" LowerOfTmpTAtom"v2"; LetTAtom"chk1" A Check0 1 Write 1 TmpTAtom"v52"; RawStoreWb 0 Const0 TmpTAtom"chk1"; b_jump ≔ JGotoToTAtom"L41"; b_label ≔ TAtom"L41"; b_phis ≔ [ ]; b_insts ≔ [ ]; b_jump ≔ JRetConst34 ∧ SomeDefinedfn_name ≔ TAtom"setlocale_null_r"; fn_linkage ≔ TAtom"export"; fn_ret ≔ RClassW; fn_params ≔ W, TAtom"v0"; P, TAtom"v2"; L, TAtom"v4"; fn_blocks ≔ b_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v9" W GlobalTAtom"setlocale_null_r_unlocked" ArgW TmpTAtom"v0"; ArgP TmpTAtom"v2"; ArgL TmpTAtom"v4"; b_jump ≔ JRetTmpTAtom"v9" = SomeDefinedfn_name ≔ TAtom"setlocale_null_r"; fn_linkage ≔ TAtom"export"; fn_ret ≔ RClassW; fn_params ≔ W, TAtom"v0"; P, TAtom"v2"; L, TAtom"v4"; fn_blocks ≔ b_label ≔ TAtom"start"; b_phis ≔ [ ]; b_insts ≔ CallCResultTAtom"v9" W GlobalTAtom"setlocale_null_r_unlocked" ArgW TmpTAtom"v0"; ArgP TmpTAtom"v2"; ArgL TmpTAtom"v4"; b_jump ≔ JRetTmpTAtom"v9"

auto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros Hm
unfold find_fn
rewrite Hm
vm_compute
auto

The literals "C" and "POSIX" of hard-locale.c, read-only.

157Definition c_ptr: ptr ≔
mkPtr65824 Ro65824

Its bytes.

159Definition c_bytes: listZ ≔
67

"POSIX".

161Definition posix_ptr: ptr ≔
mkPtr65856 Ro65856

Its bytes.

163Definition posix_bytes: listZ ≔
80; 79; 83; 73; 88

Hello's symbols put the two literals there.

166Lemma locale_globals
lookupTAtom"hard-locale#str.31" hello_globals = Somec_ptr ∧ lookupTAtom"hard-locale#str.32" hello_globals = Someposix_ptr
Explore proof 2 tactics

Initial goal

⊢
lookupTAtom"hard-locale#str.31" hello_globals = Somec_ptr ∧ lookupTAtom"hard-locale#str.32" hello_globals = Someposix_ptr

vm_compute

⊢
Someptr_addr ≔ 65824; ptr_cap ≔ Ro65824 = Someptr_addr ≔ 65824; ptr_cap ≔ Ro65824 ∧ Someptr_addr ≔ 65856; ptr_cap ≔ Ro65856 = Someptr_addr ≔ 65856; ptr_cap ≔ Ro65856

auto

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
vm_compute
auto

What setlocale_null_r_unlocked leaves in an n-byte buffer for the name t: the result r, the string u now at the buffer's start and the buffer's bytes ys. A name shorter than the buffer is copied with its NUL and r is 0; a longer one is cut to n - 1 bytes and a NUL, and r is ERANGE (34).

176Definition snru_resultt : listZ n : nat r : Z u ys : listZ : Prop ≔
lengtht < n%nat ∧ r = 0 ∧ u = t ∨ n ≤ lengtht%nat ∧ r = 34 ∧ u = taken − 1 t ∧ lengthys = n ∧ takeSlengthu ys = u ++ 0

Take every branch of the goal's conditions: each path is safe.

181Ltac all_cases  ≔
repeat match goal with|- context [if ?t then _ else _]⇒destruct tend;cbn [ edge_label ]

The triples

The locale helpers over any runtime R.

187Module HelloLocaleOn R : Runtime LG0 : LogicSigR
188Module HL ≔ HelloLeafOn R LG0
189Module LL ≔ HL.LL
190Module ML ≔ HL.ML
191Module SL ≔ ML.SL
192Module LG ≔ ML.LG
193Module L ≔ LG.L
Import L LG SL ML LL HL
196Section locale
197Context `{!invGS_genhlc Σ, !gen_heapGSpiece pval Σ}
198Context world : Type registry : name → optioncontractworld wi : mem → world → gmappiece pval → Prop `{!SafepointStablewi} ge : genv

The genv links Hello, whose world interpretation keeps every lent string where lent_at says.

203Context Hlinked : hello_linkedge
203Context wi_lent : ∀m w h k p t, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t

setlocale's contract spec answers a query, of a category whose name the world lends, with that name, changing nothing; the query's arguments are admitted wherever the name is lent.

210Context set_spec : contractworld
210Context Hset : registryTAtom"setlocale" = Someset_spec
210Context Hset_ret : contract_returnsset_spec = RClassP
210Context Hset_abi : ∀d c v, contract_abiset_spec CResultd P ArgW c; ArgP v
210Context Hset_pre : ∀m w h k p t z, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
210Context Hset_query : ∀r args s m w h k p t z trace ending s′ m′ w′, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp

strlen and memcpy have their contracts.

221Context Hstrlen : registryTAtom"strlen" = Somestrlen_contractworld
221Context Hmemcpy : registryTAtom"memcpy" = Somememcpy_contractworld

The world interpretation survives a copy into a block the program owns, whatever bytes it leaves there, and a byte store into one.

226Context Kcopy : ∀b reg o xs cs s n m m′ wd h ys, copy_resultm mkPtrb + o Objb s n m′ → ∀l v, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
226Context Kbyte : ∀b reg o x y m wd h, ∀l v, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
226Context Kalloc : ∀q m wd h base, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h

strcmp has its contract, for streq.

239Context Hstrcmp : registryTAtom"strcmp" = Somestrcmp_contractworld

The Iris instance of the registry and wi.

242Instance locale_irisGS: irisGS_genhlc nanofil_langregistry ge Σ ≔
nanofil_irisGSregistry wi ge

The expressions of the language.

246Notation hexpr ≔ language.exprnanofil_langregistry ge

setlocale_null_unlocked(k) returns the name the world lends for k.

249Lemma snu_spec
∀ k p t Φ
0 ≤ k < 2 ^ 32
lentk p t −∗ ▷ΦRetWPtrp −∗ WPERuninvocationsnu_fn WIntk : hexpr {Φ}
Explore proof 11 tactics

Initial goal

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
⊢
0 ≤ k < 2 ^ 32 → lentk p t −∗ ▷ΦRetWPtrp −∗ WPERuninvocationsnu_fn WIntk : hexpr {v. Φv}

intros Hk32

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
⊢
lentk p t −∗ ▷ΦRetWPtrp −∗ WPERuninvocationsnu_fn WIntk : hexpr {v. Φv}

iIntros #Hk HΦ

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
Hk :
lentk p t
□
HΦ :
▷ΦRetWPtrp
∗

rewrite snu_entry

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
Hk :
lentk p t
□
HΦ :
▷ΦRetWPtrp
∗
WPERunfr_fn ≔ snu_fn; fr_env ≔ TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ EnterTAtom"start" None {v. Φv}

iApply wp_enter ; exact find_u_start | reflexivity |

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
Hk :
lentk p t
□
HΦ :
▷ΦRetWPtrp
∗
▷WPHelloLocaleOn.LG.L.ERunfr_fn ≔ snu_fn; fr_env ≔ TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ ExecTAtom"start" b_instsu_start b_jumpu_start {v. Φv}

iNext

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
Hk :
lentk p t
□
HΦ :
∗
WPHelloLocaleOn.LG.L.ERunfr_fn ≔ snu_fn; fr_env ≔ TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ ExecTAtom"start" b_instsu_start b_jumpu_start {v. Φv}

cbn [ b_insts b_jump u_start ]

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
Hk :
lentk p t
□
HΦ :
∗
WPHelloLocaleOn.LG.L.ERunfr_fn ≔ snu_fn; fr_env ≔ TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ ExecTAtom"start" CallCResultTAtom"v4" P GlobalTAtom"setlocale" ArgW TmpTAtom"v0"; ArgP Const0 JRetTmpTAtom"v4" {v. Φv}

iApply wp_lent_query_ _ _ _ _ _ _ _ _ _ _ _ set_spec WIntk; WPtrmkPtr0 CNone k p t with Hk ; exact Hset | exact Hset_ret | apply linked_outside ; exact Hlinked | reflexivity | apply linked_unbound ; exact Hlinked | reflexivity | reflexivity | cbn ; rewrite Z.mod_small ; reflexivity | exact Hk32 | apply Hset_abi | intros m w h Hw Hl ; exact Hset_prem w h k p t mkPtr0 CNone Hw Hl eq_refl | intros s m w h tr en s′ m′ w′ Hw Hl Hi ; exact Hset_query_ _ s m w h k p t mkPtr0 CNone tr en s' m' w' Hw Hl eq_refl Hi |

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
Hk :
lentk p t
□
HΦ :
∗
▷WPHelloLocaleOn.LL.L.ERunfr_fn ≔ snu_fn; fr_env ≔ putTAtom"v4" WPtrp TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ ExecTAtom"start" [ ] JRetTmpTAtom"v4" {v. Φv}

iNext

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
Hk :
lentk p t
□
HΦ :
∗
WPHelloLocaleOn.LL.L.ERunfr_fn ≔ snu_fn; fr_env ≔ putTAtom"v4" WPtrp TAtom"v0", WIntk; fr_locals ≔ [ ]; fr_doomed ≔ None; fr_at ≔ ExecTAtom"start" [ ] JRetTmpTAtom"v4" {v. Φv}

iApply wp_ret ; reflexivity | reflexivity |

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
Hk :
lentk p t
□
HΦ :
∗
▷ΦRetWPtrp

iNext

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
k :
Z
p :
t :
listZ
Φ :
outcome → iPropIΣ
Hk32 :
0 ≤ k < 2 ^ 32
Hk :
lentk p t
□
HΦ :
∗

iExact HΦ

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
intros Hk32
iIntros #Hk HΦ
rewrite snu_entry
iApply wp_enter ; exact find_u_start | reflexivity |
iNext
iApply wp_lent_query_ _ _ _ _ _ _ _ _ _ _ _ set_spec WIntk; WPtrmkPtr0 CNone k p t with Hk ; exact Hset | exact Hset_ret | apply linked_outside ; exact Hlinked | reflexivity | apply linked_unbound ; exact Hlinked | reflexivity | reflexivity | cbn ; rewrite Z.mod_small ; reflexivity | exact Hk32 | apply Hset_abi | intros m w h Hw Hl ; exact Hset_prem w h k p t mkPtr0 CNone Hw Hl eq_refl | intros s m w h tr en s′ m′ w′ Hw Hl Hi ; exact Hset_query_ _ s m w h k p t mkPtr0 CNone tr en s' m' w' Hw Hl eq_refl Hi |
iNext
iApply wp_ret ; reflexivity | reflexivity |
iNext
iExact HΦ

setlocale_null_r_unlocked(k, buf, n), for the n-byte block of the bytes xs and the slots cs at the start of the live object b, at a multiple of 8, and the name t the world lends for k: it leaves snru_result in the block and returns its r.

268Lemma snru_spec
∀ k p t b reg xs cs Φ
0 ≤ k < 2 ^ 32
0 < b
b mod 8 = 0
lengthcs = lengthxs
0 < lengthxs%nat
b + Z.of_natlengthxs ≤ r_endreg
r_endreg ≤ 2 ^ 48
lentk p t −∗ liveb reg −∗ bytesb 0 xs −∗ auxesb 0 cs −∗ ▷∀r u ys cs′, ⌜snru_resultt lengthxs r u ys ∧ lengthcs′ = lengthxs⌝ −∗ liveb reg −∗ bytesb 0 ys −∗ auxesb 0 cs′ −∗ ΦRetWIntr −∗ WPERuninvocationsnru_fn WIntk; WPtrmkPtrb Objb; WIntZ.of_natlengthxs : hexpr {Φ}
Proof 147 steps Qed
intros Hk32 Hb0 Hb8 Hlc Hn Hend H48
iIntros #Hk Hl Hx Hcs HΦ
iPoseProof Hk as [%Hp _]
destruct Hp as Hp & Hpt & Ht
destruct locale_fnsge proj1Hlinked as Hsnu & _ & _
rewrite snru_entry
iApply wp_enter ; exact find_r_start | reflexivity |
iNext
iApply wp_call_bind_ _ _ _ _ _ _ _ _ _ _ _ _ snu_fn invocationsnu_fn WIntk ; cbn ; rewrite Z.mod_small ; reflexivity | exact Hk32 | exact Hsnu | reflexivity |
iNext
iApply snu_spec with Hk ; exact Hk32 |
iNext
iExists _
iSplit ; iPureIntro ; reflexivity |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
iApply wp_branch_ _ _ _ _ _ _ _ _ _ 0 ; word_premise |
iNext
iApply wp_enter ; exact find_r_L10 | reflexivity |
iNext
iApply wp_strlen_lent with Hk ; exact wi_lent | exact Hstrlen | apply linked_outside ; exact Hlinked | reflexivity | apply linked_unbound ; exact Hlinked | reflexivity | word_premise |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
destruct decidelengtht < lengthxs%nat as Hfit | Hlong

The name fits: copy it with its NUL.

–iApply wp_branch_ _ _ _ _ _ _ _ _ _ 1 ; word_premise |
iNext
iApply wp_enter ; exact find_r_L27 | reflexivity |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
set c := Slengtht
iAssert bytesb 0 takec xs ∗ bytesb 0 + Z.of_natlengthtakec xs dropc xs%I with [Hx] as [Hx1 Hx2] ; rewrite - bytes_app take_drop ; iExact Hx |
iAssert auxesb 0 takec cs ∗ auxesb 0 + Z.of_natlengthtakec cs dropc cs%I with [Hcs] as [Hc1 Hc2] ; rewrite - auxes_app take_drop ; iExact Hcs |
assert Hc : lengthtakec xs = c by rewrite length_take ; lia
assert Hcc : lengthtakec cs = c by rewrite length_take ; lia
iApply wp_memcpy_lent with Hk Hl Hx1 Hc1 ; exact wi_lent | exact Hmemcpy | apply linked_outside ; exact Hlinked | reflexivity | apply linked_unbound ; exact Hlinked | reflexivity | cbn ; rewrite Z.add_0_r ; reflexivity | word_premise | rewrite Hc ; cbn ; do 2 f_equal ; unfold c ; drop_wraps_goal ; lia | rewrite Hc ; lia | rewrite Hc Hcc ; reflexivity | exact Hb8 | reflexivity | lia | rewrite Hc ; lia | intros m m′ wd h Hres Hlk Hw ; apply Kcopy_ _ _ _ _ _ _ _ _ _ _ _ Hres Hlk Hw ; rewrite length_take length_app Hc ; cbn [ length ] ; unfold c ; lia |
iNext
iIntros cs1 Hcs1 Hl Hx1 Hc1
iApply wp_ret ; reflexivity | reflexivity |
iNext
assert Ec : takelengthtakec xs t ++ 0 = t ++ 0 by rewrite Hc take_ge ; reflexivity | rewrite length_app ; cbn [ length ] ; unfold c ; lia
rewrite Ec Hc Hcc
rewrite Hc in Hcs1
iApply HΦ $! 0 t t ++ 0 ++ dropc xs cs1 ++ dropc cs with [%] Hl [Hx1 Hx2] [Hc1 Hc2]
+split ; | rewrite length_app length_drop ; lia
split ; left ; auto |
split
∗rewrite ! length_app length_drop
cbn [ length ]
unfold c
lia
∗replace Slengtht with lengtht ++ 0 by rewrite length_app ; cbn [ length ] ; lia
apply take_app_length
+iApply bytes_app
rewrite length_app
cbn [ length ]
replace 0 + Z.of_natlengtht + 1 with 0 + Z.of_natc by unfold c ; lia
iFrame
+iApply auxes_app
rewrite Hcs1
iFrame

The name does not fit: copy n - 1 bytes of it and end them with a NUL.

–iApply wp_branch_ _ _ _ _ _ _ _ _ _ 0 ; word_premise |
iNext
iApply wp_enter ; exact find_r_L28 | reflexivity |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
iApply wp_branch_ _ _ _ _ _ _ _ _ _ 1 ; word_premise |
iNext
iApply wp_enter ; exact find_r_L39 | reflexivity |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
set c := lengthxs − 1%nat
assert Hc : lengthtakec xs = c by rewrite length_take ; lia
assert Hcc : lengthtakec cs = c by rewrite length_take ; lia
destruct dropc xs as | x | x′ rest eqn: Ed ; apply f_equallength in Ed ; rewrite length_drop in Ed ; cbn in Ed ; lia | | apply f_equallength in Ed ; rewrite length_drop in Ed ; cbn in Ed ; lia
assert Eb : ∀y, byte_psb Z.of_natc y = PByteb Z.of_natc, VBytey by intros y ; rewrite byte_ps_cons ; reflexivity
iAssert bytesb 0 takec xs ∗ bytesb 0 + Z.of_natlengthtakec xs dropc xs%I with [Hx] as [Hx1 Hx2] ; rewrite - bytes_app take_drop ; iExact Hx |
rewrite Ed Hc Z.add_0_l / bytes Eb
iEval ( rewrite -/ ibyteb Z.of_natc x ) in Hx2
rewrite -/ bytesb 0 takec xs
iAssert auxesb 0 takec cs ∗ auxesb 0 + Z.of_natlengthtakec cs dropc cs%I with [Hcs] as [Hc1 Hc2] ; rewrite - auxes_app take_drop ; iExact Hcs |
rewrite Hcc
iApply wp_memcpy_lent with Hk Hl Hx1 Hc1 ; exact wi_lent | exact Hmemcpy | apply linked_outside ; exact Hlinked | reflexivity | apply linked_unbound ; exact Hlinked | reflexivity | cbn ; rewrite Z.add_0_r ; reflexivity | word_premise | rewrite Hc ; cbn ; do 2 f_equal ; unfold c ; drop_wraps_goal ; lia | rewrite Hc ; lia | rewrite Hc Hcc ; reflexivity | exact Hb8 | reflexivity | lia | rewrite Hc ; lia | intros m m′ wd h Hres Hlk Hw ; apply Kcopy_ _ _ _ _ _ _ _ _ _ _ _ Hres Hlk Hw ; rewrite length_take length_app Hc ; cbn [ length ] ; unfold c ; lia |
iNext
iIntros cs1 Hcs1 Hl Hx1 Hc1
rewrite Hc in Hcs1
iApply wp_flight_ _ _ _ _ _ _ _ _ _ _ _ _ _ b + Z.of_natc ; word_premise | cbn ; f_equal ; f_equal ; unfold c ; addr_premise | word_premise |
iNext
iApply wp_check with Hl ; reflexivity | word_premise | reflexivity | unfold c ; addr_premise | unfold c ; addr_premise | addr_premise |
iNext
iIntros Hl
iApply wp_raw_store_byte with Hl Hx2 ; word_premise | word_premise | reflexivity | unfold c ; addr_premise | intros m wd h Hlk Hw ; exact Kbyte_ _ _ _ _ _ _ _ Hlk Hw |
iNext
iIntros Hl Hx2
iApply wp_goto
iNext
iApply wp_enter ; exact find_r_L41 | reflexivity |
iNext
iApply wp_ret ; reflexivity | reflexivity |
iNext
assert Ec : takelengthtakec xs t ++ 0 = takec t by rewrite Hc take_app_le ; reflexivity | lia
rewrite Ec
iApply HΦ $! 34 takec t takec t ++ 0 cs1 ++ dropc cs with [%] Hl [Hx1 Hx2] [Hc1 Hc2]
+split ; | rewrite length_app length_drop ; lia
split ; right ; split ; lia | ; split ; reflexivity | ; reflexivity |
split
∗rewrite length_app length_take
cbn [ length ]
unfold c
lia
∗apply take_ge
rewrite length_app
cbn [ length ]
lia
+iApply bytes_app
rewrite length_take Nat.min_l ; | unfold c ; lia
rewrite Z.add_0_l / bytes Eb
iFrame Hx1
iExact Hx2
+iApply auxes_app
rewrite Hcs1
iFrame

setlocale_null_r(k, buf, n) is setlocale_null_r_unlocked's call (snru_spec): this build takes no lock.

388Lemma snr_spec
∀ k p t b reg xs cs Φ
0 ≤ k < 2 ^ 32
0 < b
b mod 8 = 0
lengthcs = lengthxs
0 < lengthxs%nat
b + Z.of_natlengthxs ≤ r_endreg
r_endreg ≤ 2 ^ 48
lentk p t −∗ liveb reg −∗ bytesb 0 xs −∗ auxesb 0 cs −∗ ▷∀r u ys cs′, ⌜snru_resultt lengthxs r u ys ∧ lengthcs′ = lengthxs⌝ −∗ liveb reg −∗ bytesb 0 ys −∗ auxesb 0 cs′ −∗ ΦRetWIntr −∗ WPERuninvocationsnr_fn WIntk; WPtrmkPtrb Objb; WIntZ.of_natlengthxs : hexpr {Φ}
Proof 18 steps Qed
intros Hk32 Hb0 Hb8 Hlc Hn Hend H48
iIntros #Hk Hl Hx Hcs HΦ
destruct locale_fnsge proj1Hlinked as _ & Hsnru & _
rewrite snr_entry
iApply wp_enter ; exact find_n_start | reflexivity |
iNext
iApply wp_call_bind_ _ _ _ _ _ _ _ _ _ _ _ _ snru_fn invocationsnru_fn WIntk; WPtrmkPtrb Objb; WIntZ.of_natlengthxs ; cbn ; rewrite ! Z.mod_small ; reflexivity | lia | exact Hk32 | exact Hsnru | reflexivity |
iNext
iApply snru_spec with Hk Hl Hx Hcs ; exact Hk32 | exact Hb0 | exact Hb8 | exact Hlc | exact Hn | exact Hend | exact H48 |
iNext
iIntros r u ys cs′ Hr Hl Hx Hcs
iExists _
iSplit ; iPureIntro ; reflexivity |
iNext
assert Hr32 : r = 0 ∨ r = 34 by destruct Hr as _ & → & _ | _ & → & _ & _ & _ ; auto
destruct Hr32 as → | → ; iApply wp_ret ; reflexivity | reflexivity | ; iNext ; iApply HΦ with [%] Hl Hx Hcs ; exact Hr

The genv's literals are Hello's, and streq and setlocale_null_r are its functions.

416Lemma hard_locale_lookups
lookupTAtom"hard-locale#str.31" ge_globalsge = Somec_ptr ∧ lookupTAtom"hard-locale#str.32" ge_globalsge = Someposix_ptr ∧ find_fnge TAtom"streq" = SomeDefinedstreq_fn ∧ find_fnge TAtom"setlocale_null_r" = SomeDefinedsnr_fn
Explore proof 5 tactics

Initial goal

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
⊢
lookupTAtom"hard-locale#str.31" ge_globalsge = Somec_ptr ∧ lookupTAtom"hard-locale#str.32" ge_globalsge = Someposix_ptr ∧ find_fnge TAtom"streq" = SomeDefinedstreq_fn ∧ find_fnge TAtom"setlocale_null_r" = SomeDefinedsnr_fn

destruct locale_globals as H1 & H2

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
H1 :
lookupTAtom"hard-locale#str.31" hello_globals = Somec_ptr
H2 :
lookupTAtom"hard-locale#str.32" hello_globals = Someposix_ptr
⊢
lookupTAtom"hard-locale#str.31" ge_globalsge = Somec_ptr ∧ lookupTAtom"hard-locale#str.32" ge_globalsge = Someposix_ptr ∧ find_fnge TAtom"streq" = SomeDefinedstreq_fn ∧ find_fnge TAtom"setlocale_null_r" = SomeDefinedsnr_fn

destruct Hlinked as Hm & Hg & _

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
H1 :
lookupTAtom"hard-locale#str.31" hello_globals = Somec_ptr
H2 :
lookupTAtom"hard-locale#str.32" hello_globals = Someposix_ptr
Hg :
∀n : name p : ptr, lookupn hello_globals = Somep → lookupn ge_globalsge = Somep
⊢
lookupTAtom"hard-locale#str.31" ge_globalsge = Somec_ptr ∧ lookupTAtom"hard-locale#str.32" ge_globalsge = Someposix_ptr ∧ find_fnge TAtom"streq" = SomeDefinedstreq_fn ∧ find_fnge TAtom"setlocale_null_r" = SomeDefinedsnr_fn

split ; exact Hg_ _ H1 |

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
H1 :
lookupTAtom"hard-locale#str.31" hello_globals = Somec_ptr
H2 :
lookupTAtom"hard-locale#str.32" hello_globals = Someposix_ptr
Hg :
∀n : name p : ptr, lookupn hello_globals = Somep → lookupn ge_globalsge = Somep
⊢
lookupTAtom"hard-locale#str.32" ge_globalsge = Someposix_ptr ∧ find_fnge TAtom"streq" = SomeDefinedstreq_fn ∧ find_fnge TAtom"setlocale_null_r" = SomeDefinedsnr_fn

split ; exact Hg_ _ H2 |

hlc :
has_lc
Σ :
gFunctors
invGS_gen0 :
invGS_genhlc Σ
gen_heapGS0 :
gen_heapGSpiece pval Σ
world :
Type
registry :
name → optioncontractworld
wi :
mem → world → gmappiece pval → Prop
SafepointStable0 :
ge :
Hlinked :
wi_lent :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ, wim w h → live_disjointm → objects_fitm_regionsm → freed_emptym_regionsm → h !! PNamek = SomeVNamep t → lent_atm h p t
set_spec :
Hset :
registryTAtom"setlocale" = Someset_spec
Hset_ret :
Hset_abi :
∀d : name c v : value, contract_abiset_spec CResultd P ArgW c; ArgP v
Hset_pre :
∀m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → contract_preset_spec WIntk; WPtrz m w
Hset_query :
∀r : call_result args : listarg s : R.state m : mem w : world h : gmappiece pval k : Z p : ptr t : listZ z : ptr trace : listevent ending : call_end s′ : R.state m′ : mem w′ : world, wim w h → h !! PNamek = SomeVNamep t → ptr_addrz = 0 → M.E.invokeset_spec r args WIntk; WPtrz s m w trace ending s′ m′ w′ → s′ = s ∧ m′ = m ∧ w′ = w ∧ ending = CallReturnWPtrp
Hstrlen :
registryTAtom"strlen" = Somestrlen_contractworld
Hmemcpy :
registryTAtom"memcpy" = Somememcpy_contractworld
Kcopy :
∀b : Z reg : region o : Z xs : listZ cs : listcap s : ptr n : Z m m′ : mem wd : world h : gmappiece pval ys : listZ, copy_resultm ptr_addr ≔ b + o; ptr_cap ≔ Objb s n m′ → ∀l : piece v : pval, l, v ∈ block_psb reg o xs cs → h !! l = Somev → wim wd h → lengthys = lengthxs → wim′ wd overwriteblock_psb reg o ys slots_afterm′ b o lengthxs h
Kbyte :
∀b : Z reg : region o x y : Z m : mem wd : world h : gmappiece pval, ∀l : piece v : pval, l, v ∈ PLiveb, VLivereg; PByteb o, VBytex → h !! l = Somev → wim wd h → wistore_bytesm b + o 1 y wd overwritePLiveb, VLivereg; PByteb o, VBytey mod 256 h
Kalloc :
∀q : alloc_req m : mem wd : world h : gmappiece pval base : Z, freshm q base → wim wd h → wiallocatedm q base wd overwriteobj_psbase q h
Hstrcmp :
registryTAtom"strcmp" = Somestrcmp_contractworld
H1 :
lookupTAtom"hard-locale#str.31" hello_globals = Somec_ptr
H2 :
lookupTAtom"hard-locale#str.32" hello_globals = Someposix_ptr
Hg :
∀n : name p : ptr, lookupn hello_globals = Somep → lookupn ge_globalsge = Somep
⊢
find_fnge TAtom"streq" = SomeDefinedstreq_fn ∧ find_fnge TAtom"setlocale_null_r" = SomeDefinedsnr_fn

split ; unfold find_fn ; rewrite Hm ; vm_compute ; reflexivity | exact proj2proj2locale_fnsge Hm

No remaining goals.

Qed

✓ Proof checked and closed by Rocq.

Source script
destruct locale_globals as H1 & H2
destruct Hlinked as Hm & Hg & _
split ; exact Hg_ _ H1 |
split ; exact Hg_ _ H2 |
split ; unfold find_fn ; rewrite Hm ; vm_compute ; reflexivity | exact proj2proj2locale_fnsge Hm

hard_locale(k), for the name t the world lends for k, and the literals "C" and "POSIX" owned as strings: it copies the name into a fresh 257-byte buffer, compares it with both, and returns.

430Lemma hard_locale_spec
∀ k p t rc rp Φ
0 ≤ k < 2 ^ 32
lentk p t −∗ stringc_ptr 65824 rc c_bytes −∗ stringposix_ptr 65856 rp posix_bytes −∗ ▷∀r, stringc_ptr 65824 rc c_bytes −∗ stringposix_ptr 65856 rp posix_bytes −∗ ΦRetWIntr −∗ WPERuninvocationhard_locale_fn WIntk : hexpr {Φ}
Proof 116 steps Qed
intros Hk32
iIntros #Hk Hc Hposix HΦ
iPoseProof Hk as [%Hp _]
destruct Hp as Hp & Hpt & Ht
destruct hard_locale_lookups as Hlc & Hlp & Hstreq & Hsnr
iApply wp_enter ; exact find_h_start | reflexivity |
iNext
iApply wp_alloc_ _ _ _ _ _ _ _ _ _ _ _ _ 257 ; reflexivity | lia | unfold max_allocation_size ; lia | intros m wd h base Hf Hw ; exact Kalloc_ _ _ _ _ Hf Hw |
iNext
iIntros base Hbase Hobj
destruct Hbase as Hb0 & Hb16 & Hb48
change base mod 16 = 0 in Hb16
change base + 272 ≤ 2 ^ 48 in Hb48
iDestruct obj_zero_block with Hobj as (Hl & Hx & Hcs) ; compute ; discriminate |
assert Hext : req_extentheap_req4 257 = 272 by reflexivity
rewrite Hext in Hb48 |- *
match goal with|- context [livebase ?r]⇒set reg := rend
iAssert bytesbase 0 replicate257 0%I with [Hx] as Hx
{rewrite _ : Z.to_nat272 = 257 + 15%nat ; | reflexivity
rewrite replicate_add bytes_app
iDestruct Hx as [$ _]
iAssert auxesbase 0 replicate257 CNone%I with [Hcs] as Hcs
{rewrite _ : Z.to_nat272 = 257 + 15%nat ; | reflexivity
rewrite replicate_add auxes_app
iDestruct Hcs as [$ _]
iApply wp_call_bind_ _ _ _ _ _ _ _ _ _ _ _ _ snr_fn invocationsnr_fn WIntk; WPtrmkPtrbase Objbase; WIntZ.of_natlengthreplicate257 0 ; cbn ; rewrite Z.mod_small ; reflexivity | exact Hk32 | exact Hsnr | reflexivity |
iNext
iApply snr_spec with Hk Hl Hx Hcs ; exact Hk32 | exact Hb0 | pose proof Z.div_modbase 16 ltac:lia ; pose proof Z.div_modbase 8 ltac:lia ; pose proof Z.mod_pos_boundbase 8 ltac:lia ; lia | rewrite ! length_replicate ; reflexivity | rewrite length_replicate ; lia | rewrite length_replicate ; unfold reg ; cbn [ r_end ] ; change Z.of_nat257 with 257 ; lia | unfold reg ; cbn [ r_end ] ; lia |
iNext
iIntros r u ys cs′ Hr _ Hl Hx Hcs
iExists _
iSplit ; iPureIntro ; reflexivity |
iNext
rewrite length_replicate in Hr
destruct Hr as Hfit & → & → | Hlong & → & → & Hys & Htake

The name fit: compare it with "C", then "POSIX".

–iApply wp_branch_ _ _ _ _ _ _ _ _ _ 0 ; word_premise |
iNext
iApply wp_enter ; exact find_h_L5 | reflexivity |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
iAssert bytesbase 0 t ++ 0 ∗ bytesbase 0 + Z.of_natlengthtakeSlengtht ys dropSlengtht ys%I with [Hx] as [Hx _] ; rewrite - Htake - bytes_app take_drop ; iExact Hx |
iDestruct block_stringbase reg 0 t with Hl Hx as Hs
{split ; left ; reflexivity |
unfold reg ; cbn [ ptr_addr r_end ]
split ; exact Hb0 |
split ; lia |
split ; lia |
split ; lia | exact Ht
rewrite Z.add_0_r
iApply wp_call_bind_ _ _ _ _ _ _ _ _ _ _ _ _ streq_fn invocationstreq_fn WPtrmkPtrbase Objbase; WPtrc_ptr ; word_premise | exact Hstreq | reflexivity |
iNext
iApply streq_specregistry wi ge Hlinked with Hs Hc ; exact Hstrcmp |
iNext
iIntros k1 Hs Hc
iExists _
iSplit ; iPureIntro ; reflexivity |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
iNext
+iApply wp_enter ; exact find_h_L16 | reflexivity |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
iApply wp_call_bind_ _ _ _ _ _ _ _ _ _ _ _ _ streq_fn invocationstreq_fn WPtrmkPtrbase Objbase; WPtrposix_ptr ; word_premise | exact Hstreq | reflexivity |
iNext
iApply streq_specregistry wi ge Hlinked with Hs Hposix ; exact Hstrcmp |
iNext
iIntros k2 Hs Hposix
iExists _
iSplit ; iPureIntro ; reflexivity |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
iApply wp_let ; reflexivity | reflexivity | word_premise | intros m ; word_premise |
iNext
iApply wp_goto
iNext
iApply wp_enter ; exact find_h_L17 | word_premise |
iNext
iNext
all_cases ; first iApply wp_enter ; exact find_h_L10 | reflexivity | | iApply wp_enter ; exact find_h_L12 | reflexivity | ; iNext ; cbn [ b_insts b_jump h_L10 h_L12 ] ; iApply wp_ret ; reflexivity | reflexivity | ; iNext ; iApply HΦ with Hc Hposix
+iApply wp_enter ; exact find_h_L17 | word_premise |
iNext
iApply wp_branch_ _ _ _ _ _ _ _ _ _ 1 ; word_premise |
iNext
iApply wp_enter ; exact find_h_L12 | reflexivity |
iNext
iApply wp_ret ; reflexivity | reflexivity |
iNext
iApply HΦ with Hc Hposix

The name did not fit: not a hard locale.

–iApply wp_branch_ _ _ _ _ _ _ _ _ _ 34 ; word_premise |
iNext
iApply wp_enter ; exact find_h_L3 | reflexivity |
iNext
iApply wp_ret ; reflexivity | reflexivity |
iNext
iApply HΦ with Hc Hposix

HelloLocaleOn over a Logic instance of its own.

517Module HelloLocale R : Runtime
518Module LG0 ≔ Logic R
Include HelloLocaleOn R LG0