Ranvier.Pure.Extensions

Reading settings

Look

Mode

Definitions

Proofs

Imports

Arguments

References

References open

Saved in this browser.

ModulesGuarantees

Modules

Audit0Extract12

Base

Prelude9Syntax43

Reference

Semantics63Properties202

Pure

ObserverSet29SourceList104State16Edges12Marking117Engine103Check204Runs259Scheduler241Ownership49WholeGraph562Refinement465Witnesses244Optimised271Ledger6Collections302Concurrency141Extensions123Deltas68FastPaths435Combinators106MemoTable147MemoTableWitnesses62MemoTableFastPaths113

Heap

ObserverSet46SourceList89Ghost160Marking22Run286Scheduler7Ownership29Adequacy3Collections38Concurrency41Extensions17Deltas10MemoTable28

Conformance

Expected64Check119
On this page

On this page

Ranvier.Query and Ranvier.Elmish boundary contracts1. PublicationComparer (CmpNever) with explicit equality gatingguarded_pub_writepublication_comparer_guarded_refines_cutoff2. QueryEntry generation-fenced publication and stale-while-revalidatefetch_statusfetch_status_eq_decquery_entry_stateqe_startqe_publishqe_disposequery_publish_fencedquery_refresh_retains_data3. Reference-counted QueryLease lifecyclequery_lease_statequery_lease_disposequery_lease_dispose_idempotent_refcount4. Two-phase atomic QueryStaging commit and reentrancy guarddraft_editquery_draft_stateinit_draftapply_draft_editapply_draft_editsclient_reentrancy_allowedcommit_stagingquery_commit_atomic_staging5. Ranvier.Elmish (Mvu.fs) scope-gated dispatch and command orderingmvu_statemvu_cmdmvu_run_cmdsmvu_applymvu_disposed_drops_dispatchobs_cmdmvu_apply_writes_before_commands6. Elmish untracked/unjournaled bypass, lazy gate, inline staging, QueryKey, and linked leasesarrive_envarrive_run_untrackedarrive_fastcmd_workrun_cmds_journaled_specrun_cmds_optmvu_untracked_bypass_and_direct_cmd_eqgate_stateeager_entrylazy_entryeager_initlazy_initgate_opeval_gatestep_eagerensure_gatestep_lazyrun_eagerrun_lazyentry_gate_relreads_while_emptylazy_query_gate_refines_eagerext_draft_editinline_draftinit_inline_draftstep_inline_draftapply_inline_draftsto_model_editdecode_draftinline_preparemodel_preparecommit_reset_draftunboxed_data_and_inline_draft_refines_staged_mapqk_default_eqqk_default_hashsession_guard_oksingle_checked_opdouble_checked_opquery_key_default_equatable_and_session_guard_eqawait_outcomeawait_immediate_decisionawait_waiter_specawait_fast_optlinked_lease_statelinked_lease_disposewaiter_fast_task_and_linked_lease_eq7. Wave 6 CSharp, Wire, Mcp, and Dom optimisationsbound_statusbound_readingdecode_struct_readingbound_stateeq_opt_natbound_refresh_flagsbound_refresh_allocbound_refresh_reusedirect_signal_dispatchqueued_signal_dispatchbound_slot_inplace_refresh_and_direct_dispatch_eqrc_staterc_task_outcomerc_task_outcome_eq_decrc_sync_with_ctsrc_sync_directrc_onthread_tasknotify_deliverednotify_eagerreactive_command_inline_exec_and_lazy_notify_eqany_pending_loopexposure_rev_diffexposure_filter_diffmodifier_key_namesis_modifier_key_matchdispatch_dom_observersany_pending_loop_and_unsubscribed_publish_eqis_high_surris_low_surris_any_surrlone_surr_fromprescan_plain_loopwire_surrogate_prefix_skip_and_char_scalar_eqstrip_leading_zerosmantissa_digitsz_cmplist_lex_cmpstep_mantissa_scanscan_mantissaref_fits_mantissascan_fits_mantissawire_property_order_member_dedup_and_decimal_scan_eqwire_stop_lanewire_scalar_stoptrailing_clearwire_block_stopwire_block_stop_appwire_vector_stop_eqmvu_select_unit_history
This definition

Ranvier.Pure.Extensions

Ranvier.Query and Ranvier.Elmish boundary contracts

Ranvier.Query (Types.fs, Entry.fs, Queries.fs, Mutations.fs) and Ranvier.Elmish (Mvu.fs) build higher-level state management on top of the core reactive graph. To keep their implementation open to internal optimization while guaranteeing their documented consumer contracts, this module proves the exact minimum specifications required at their boundaries:

  1. PublicationComparer (CmpNever) with explicit equality gating (Types.fs, Entry.fs):
  2. QueryEntry generation-fenced publication and stale-while-revalidate (Entry.fs):
    • query_publish_fenced: qe_publish mutates the entry if and only if the entry is not disposed and the completing flight's generation matches the current generation (flight_gen = qe_gen); stale or post-disposal flights are ignored.
    • query_refresh_retains_data: starting a refresh (qe_start) or receiving a refresh failure (qe_publish with Inr err) when cached data Some v is present retains qe_data = Some v, records qe_error = Some err and qe_stale = true, and never faults the initial-load gate.
  3. Reference-counted QueryLease lifecycle (Queries.fs):
    • query_lease_dispose_idempotent_refcount: disposing a QueryLease is idempotent (lease_disposed guards the release callback), decrements the family's reference count at most once, and evicts/disposes the shared QueryEntry if and only if the last active lease releases (count = 1).
  4. Two-phase atomic QueryStaging commit and reentrancy guard (Types.fs, Queries.fs):
    • query_commit_atomic_staging: QueryDraft edits compose in order on loaded entries while leaving unloaded entries empty and stale; staging = true blocks reentrant client calls during Prepare(); and if validation fails during Prepare(), zero cache entries are mutated.
  5. Ranvier.Elmish (Mvu.fs) scope-gated dispatch and command ordering:
6
From stdpp Require Import prelude gmap strings.
From Stdlib Require Import ZArith.
From Stdlib Require String.
From Ranvier.Base Require Import Prelude Syntax.
From Ranvier.Pure Require Import ObserverSet SourceList State Marking Engine.
Open Scope nat_scope.

1. PublicationComparer (CmpNever) with explicit equality gating

Models the Entry.fs lines 55–65 / 231–249 publication pattern: the signal n is constructed with PublicationComparer (CmpNever), and the caller evaluates changed before the batch, writing n only when changed = true.

Definition guarded_pub_write (changed : bool) (fuel : nat) (n : node_id) (v : Z) (s : state)
    : option (state * unit) :=
  if changed then write_signal fuel n v s else Some (s, tt).
References

Uses

2 more
  • unit
  • Z
✓ No axioms

Gating a CmpNever signal write behind bool_decide (n_value d <> v) preserves exact equality cutoff when n_value d = v and wakes all observers (ends_dirty) when n_value d <> v.

Proves the PublicationComparer optimization contract (Types.fs lines 133–136, Entry.fs lines 10–16, 55–65, 231–249): precomputing changed outside graph.Batch over a CmpNever signal avoids comparing a second time inside Signal.Set while preserving both halves of the signal cutoff contract:

  • When n_value d = v, guarded_pub_write is a no-op (Some (s, tt)), waking zero observers.
  • When n_value d <> v, publishing v updates n and marks every observer m dirty (ends_dirty s1 m).

Arguments

fuel : nat
the marking fuel.
the signal node id.
v : Z
the published value.
d : node
the signal descriptor at n with n_kind d = KSignal and n_comparer d = CmpNever.
s : state
the graph state before publication.
Theorem publication_comparer_guarded_refines_cutoff
    (fuel : nat) (n : node_id) (v : Z) (d : node) (s : state) :
  g_nodes s !! n = Some d ->
  n_kind d = KSignal ->
  n_comparer d = CmpNever ->
  (n_value d = v ->
   guarded_pub_write (bool_decide (n_value d <> v)) fuel n v s = Some (s, tt)) /\
  (n_value d <> v ->
   forall s1 m,
     m ∈ observer_view (observers_of (g_edges s) n) ->
     takes_marks s m ->
     (g_current s <> Some m \/ n ∈ read_prefix (g_edges s) m) ->
     notify_dirty_except fuel n (g_current s) (ghost_publish n (set_node n (node_with_value v d) s)) = Some s1 ->
     ends_dirty s1 m).

Arguments

fuel : nat
the marking fuel.
the signal node id.
v : Z
the published value.
d : node
the signal descriptor at n with n_kind d = KSignal and n_comparer d = CmpNever.
s : state
the graph state before publication.
Qed
Proof.
  intros Hd Hk Hcmp. split.
  - intros Heq. unfold guarded_pub_write.
    rewrite bool_decide_eq_false_2; [done|].
    intros Hne. exact (Hne Heq).
  - intros Hne s1 m Hin Ht Hcond Hnot.
    set (s_pub := ghost_publish n (set_node n (node_with_value v d) s)) in *.
    assert (Hedges : g_edges s_pub = g_edges s) by (subst s_pub; unfold ghost_publish; simpl; rewrite lookup_insert_eq; done).
    assert (Ht_pub : takes_marks s_pub m).
    { destruct Ht as (dm & Hdm & Hkm).
      assert (Hmn : m <> n).
      { intros ->. rewrite Hd in Hdm. injection Hdm as <-.
        destruct Hkm as [Hkm|[Hkm _]]; congruence. }
      exists dm. subst s_pub. unfold ghost_publish. simpl.
      rewrite lookup_insert_eq. simpl. rewrite lookup_insert_ne by done. done. }
    eapply (notify_dirty_ends_dirty fuel n (g_current s) s_pub s1 m).
    + by rewrite Hedges.
    + exact Ht_pub.
    + right. rewrite Hedges. done.
Qed.
References

2. QueryEntry generation-fenced publication and stale-while-revalidate

Inductive fetch_status :=
  | FsIdle
  | FsFetching.
References
Global Instance fetch_status_eq_dec : EqDecision fetch_status.
Defined
Proof. solve_decision. Defined.
References

Uses

Pure state of a QueryEntry<'T> (Entry.fs lines 9–21):

  • qe_data: accepted cached record (None before initial load settles, Some v afterwards).
  • qe_status: FsIdle or FsFetching.
  • qe_error: failure from the latest attempt, or None.
  • qe_stale: whether Ensure should start a fresh request.
  • qe_gen: monotonic flight generation counter (generation in Entry.fs).
  • qe_disposed: whether Dispose has retired the entry.
  • qe_gate_faulted: whether the initial-load suspension gate (AsyncSource) was faulted.
Record query_entry_state := {
  qe_data : option Z;
  qe_status : fetch_status;
  qe_error : option nat;
  qe_stale : bool;
  qe_gen : nat;
  qe_disposed : bool;
  qe_gate_faulted : bool;
}.
References

Uses

Entry.start (Entry.fs lines 145–159): increments qe_gen, cancels any superseded flight, replaces gate only when qe_data = None, and transitions metadata to (FsFetching, None, true) while retaining qe_data.

Definition qe_start (qe : query_entry_state) : query_entry_state :=
  if qe_disposed qe then qe
  else
    {| qe_data := qe_data qe;
       qe_status := FsFetching;
       qe_error := None;
       qe_stale := true;
       qe_gen := S (qe_gen qe);
       qe_disposed := false;
       qe_gate_faulted := false |}.
References

Entry.publish (Entry.fs lines 48–106): accepts outcome (inl v for Result.Ok v, inr err for Result.Error err) if and only if not (qe_disposed qe) and flight_gen = qe_gen qe.

Definition qe_publish (flight_gen : nat) (outcome : Z + nat) (qe : query_entry_state) : query_entry_state :=
  if decide (qe_disposed qe = false /\ flight_gen = qe_gen qe) then
    match outcome with
    | inl v =>
        {| qe_data := Some v;
           qe_status := FsIdle;
           qe_error := None;
           qe_stale := false;
           qe_gen := qe_gen qe;
           qe_disposed := false;
           qe_gate_faulted := false |}
    | inr err =>
        {| qe_data := qe_data qe;
           qe_status := FsIdle;
           qe_error := Some err;
           qe_stale := true;
           qe_gen := qe_gen qe;
           qe_disposed := false;
           qe_gate_faulted := bool_decide (qe_data qe = None) |}
    end
  else qe.
References

Entry.Dispose (Entry.fs lines 275–281): marks qe_disposed = true and advances qe_gen.

Definition qe_dispose (qe : query_entry_state) : query_entry_state :=
  if qe_disposed qe then qe
  else
    {| qe_data := qe_data qe;
       qe_status := qe_status qe;
       qe_error := qe_error qe;
       qe_stale := qe_stale qe;
       qe_gen := S (qe_gen qe);
       qe_disposed := true;
       qe_gate_faulted := qe_gate_faulted qe |}.
References
✓ No axioms

qe_publish mutates the entry only for the active generation of a live entry; superseded or post-disposal completions are no-ops.

Proves the generation-fencing contract (Entry.fs lines 48–106, 151–158, 275–281):

  • Any completion whose flight_gen <> qe_gen qe or that arrives after qe_dispose leaves qe untouched.
  • In particular, starting a refresh (qe_start) or disposing the entry (qe_dispose) advances qe_gen from g to S g, so any late reply from generation g is ignored.

Arguments

flight_gen : nat
the generation of the completing request.
outcome : Z + nat
the request outcome (inl v or inr err).
the query entry state.
Theorem query_publish_fenced (flight_gen : nat) (outcome : Z + nat) (qe : query_entry_state) :
  (qe_disposed qe = true \/ flight_gen <> qe_gen qe ->
   qe_publish flight_gen outcome qe = qe) /\
  (qe_publish (qe_gen qe) outcome (qe_start qe) = qe_start qe) /\
  (qe_publish (qe_gen qe) outcome (qe_dispose qe) = qe_dispose qe).

Arguments

flight_gen : nat
the generation of the completing request.
outcome : Z + nat
the request outcome (inl v or inr err).
the query entry state.
Qed
Proof.
  split_and!.
  - intros Hbad. unfold qe_publish.
    rewrite decide_False; [done|].
    intros [Hlive Hgen]. destruct Hbad as [Hdisp|Hne]; congruence.
  - unfold qe_publish, qe_start.
    destruct (qe_disposed qe) eqn:Edisp.
    + rewrite decide_False; [done|]. intros [Hfalse _]. congruence.
    + simpl. rewrite decide_False; [done|]. intros [_ Hgen]. lia.
  - unfold qe_publish, qe_dispose.
    destruct (qe_disposed qe) eqn:Edisp.
    + rewrite decide_False; [done|]. intros [Hfalse _]. congruence.
    + simpl. done.
Qed.
References
✓ No axioms

Refreshing a loaded QueryEntry (qe_data = Some v) or failing a refresh retains qe_data = Some v and never faults the initial-load gate.

Proves the stale-while-revalidate contract (Entry.fs lines 81–100, 111–115, 167–185):

  • When qe_data qe = Some v, qe_start preserves qe_data = Some v while setting qe_status = FsFetching and qe_stale = true.
  • When qe_data qe = Some v and the active flight fails (outcome = inr err), qe_publish preserves qe_data = Some v, records qe_error = Some err and qe_stale = true, and keeps qe_gate_faulted = false (only an initial load failure with qe_data = None faults the gate).

Arguments

v : Z
the previously accepted cached record.
err : nat
the refresh error code.
the query entry state.
Theorem query_refresh_retains_data (v : Z) (err : nat) (qe : query_entry_state) :
  qe_disposed qe = false ->
  qe_data qe = Some v ->
  let qe_refresh := qe_start qe in
  let qe_failed := qe_publish (qe_gen qe_refresh) (inr err) qe_refresh in
  qe_data qe_refresh = Some v /\
  qe_status qe_refresh = FsFetching /\
  qe_data qe_failed = Some v /\
  qe_status qe_failed = FsIdle /\
  qe_error qe_failed = Some err /\
  qe_stale qe_failed = true /\
  qe_gate_faulted qe_failed = false.

Arguments

v : Z
the previously accepted cached record.
err : nat
the refresh error code.
the query entry state.
Qed
Proof.
  intros Hlive Hdata. simpl.
  unfold qe_start, qe_publish.
  rewrite Hlive. simpl.
  rewrite decide_True by done. simpl.
  rewrite Hdata.
  rewrite bool_decide_eq_false_2; [done|discriminate].
Qed.
References

3. Reference-counted QueryLease lifecycle

State of a QueryFamily entry slot and a QueryLease (Queries.fs lines 11–83, 113–144):

  • ql_lease_disposed: whether this QueryLease has already been disposed.
  • ql_ref_count: number of active leases holding the key's QueryEntry.
  • ql_entry_alive: whether the key remains in entries with an active QueryEntry.
Record query_lease_state := {
  ql_lease_disposed : bool;
  ql_ref_count : nat;
  ql_entry_alive : bool;
}.
References

Uses

  • bool
  • nat

QueryLease.Dispose (Queries.fs lines 66–79, 127–132): if ql_lease_disposed = false, sets ql_lease_disposed := true, decrements ql_ref_count, and evicts/disposes the entry when the decremented count reaches 0.

Definition query_lease_dispose (st : query_lease_state) : query_lease_state :=
  if ql_lease_disposed st then st
  else
    let c' := ql_ref_count st - 1 in
    {| ql_lease_disposed := true;
       ql_ref_count := c';
       ql_entry_alive := bool_decide (0 < c') && ql_entry_alive st |}.
References
✓ No axioms

QueryLease.Dispose is idempotent, decrements the family reference count at most once, and evicts the shared QueryEntry iff the last active lease releases.

Proves the QueryLease ownership contract (Queries.fs lines 66–79, 125–133):

  • Disposing a lease twice equals disposing it once (query_lease_dispose (query_lease_dispose st) = query_lease_dispose st).
  • When ql_lease_disposed st = false and ql_ref_count st = S k with ql_entry_alive st = true, query_lease_dispose sets ql_ref_count to k and keeps ql_entry_alive = true iff k > 0 (evicting and disposing the entry exactly when k = 0, i.e., ql_ref_count st = 1).

Arguments

the lease and family reference-count state.
k : nat
the number of remaining leases after this lease releases.
Theorem query_lease_dispose_idempotent_refcount (st : query_lease_state) (k : nat) :
  query_lease_dispose (query_lease_dispose st) = query_lease_dispose st /\
  (ql_lease_disposed st = false ->
   ql_ref_count st = S k ->
   ql_entry_alive st = true ->
   ql_ref_count (query_lease_dispose st) = k /\
   ql_entry_alive (query_lease_dispose st) = bool_decide (0 < k)).

Arguments

the lease and family reference-count state.
k : nat
the number of remaining leases after this lease releases.
Qed
Proof.
  split.
  - unfold query_lease_dispose.
    destruct (ql_lease_disposed st) eqn:E; simpl; [rewrite E; reflexivity | reflexivity].
  - intros Hlive Hcnt Halive.
    unfold query_lease_dispose.
    rewrite Hlive, Hcnt, Halive. simpl.
    rewrite Nat.sub_0_r, andb_true_r. split; reflexivity.
Qed.
References

Uses

4 more
  • true
  • Nat.sub_0_r
  • andb_true_r
  • bool_decide

4. Two-phase atomic QueryStaging commit and reentrancy guard

A staged edit on a single QueryDraft (Types.fs lines 52–69):

  • DraftUpdate f: patches a loaded value Some v to Some (f v) and marks stale = false, updated = true; leaves an unloaded entry (None) as None with stale = true.
  • DraftInvalidate: marks the draft stale = true while preserving its data.
Inductive draft_edit :=
  | DraftUpdate (f : Z -> Z)
  | DraftInvalidate.
References

Uses

  • Z
Record query_draft_state := {
  qd_data : option Z;
  qd_stale : bool;
  qd_updated : bool;
}.
References

Uses

  • bool
  • option
  • Z
Definition init_draft (initial : option Z) : query_draft_state :=
  {| qd_data := initial; qd_stale := true; qd_updated := false |}.
References
Definition apply_draft_edit (e : draft_edit) (d : query_draft_state) : query_draft_state :=
  match e with
  | DraftUpdate f =>
      match qd_data d with
      | Some v => {| qd_data := Some (f v); qd_stale := false; qd_updated := true |}
      | None => d
      end
  | DraftInvalidate =>
      {| qd_data := qd_data d; qd_stale := true; qd_updated := qd_updated d |}
  end.
References
Fixpoint apply_draft_edits (es : list draft_edit) (d : query_draft_state) : query_draft_state :=
  match es with
  | [] => d
  | e :: rest => apply_draft_edits rest (apply_draft_edit e d)
  end.
References

Two-phase commit (Queries.fs lines 252–273): prepare_all runs all draft validations while staging = true. If prepare_all returns None (an updater or guard threw during staging), commit_staging leaves cache untouched; only when prepare_all succeeds (Some next_cache) does Publish() replace cache with next_cache.

Definition client_reentrancy_allowed (disposed staging : bool) : bool :=
  negb disposed && negb staging.
References

Uses

  • bool
  • negb
Definition commit_staging {A : Type} (prepare_all : option A) (cache : A) : A :=
  match prepare_all with
  | Some published => published
  | None => cache
  end.
References

Uses

  • None
  • Some
  • option
✓ No axioms

QueryDraft edits compose in order on loaded data, leave unloaded entries empty, reject reentrant client calls during staging, and leave the cache untouched if Prepare() fails.

Proves the QueryStaging and Commit contracts (Types.fs lines 52–80, Queries.fs lines 163–207, 234–273):

  • Applying [DraftUpdate f; DraftUpdate g] to a loaded draft (Some v) yields Some (g (f v)) with qd_stale = false and qd_updated = true.
  • Applying any sequence of DraftUpdate and DraftInvalidate edits to an unloaded draft (None) preserves qd_data = None and qd_stale = true (unloaded entries are invalidated, never fabricated).
  • While staging = true, client_reentrancy_allowed is false.
  • If prepare_all = None, commit_staging returns the original cache unmodified.

Arguments

v : Z
a loaded entry's initial value.
f : Z -> Z
the first updater function.
g : Z -> Z
the second updater function.
es : list draft_edit
an arbitrary list of draft edits.
Theorem query_commit_atomic_staging (v : Z) (f g : Z -> Z) (es : list draft_edit) :
  apply_draft_edits [DraftUpdate f; DraftUpdate g] (init_draft (Some v)) =
    {| qd_data := Some (g (f v)); qd_stale := false; qd_updated := true |} /\
  (let d_none := apply_draft_edits es (init_draft None) in
   qd_data d_none = None /\ qd_stale d_none = true) /\
  (forall disp, client_reentrancy_allowed disp true = false) /\
  (forall (A : Type) (cache : A), commit_staging None cache = cache).

Arguments

v : Z
a loaded entry's initial value.
f : Z -> Z
the first updater function.
g : Z -> Z
the second updater function.
es : list draft_edit
an arbitrary list of draft edits.
Qed
Proof.
  split_and!.
  - reflexivity.
  - assert (Hinv : forall d, qd_data d = None -> qd_stale d = true ->
              qd_data (apply_draft_edits es d) = None /\ qd_stale (apply_draft_edits es d) = true).
    { induction es as [|e rest IH]; intros d Hd Hst; [ done |].
      destruct e as [h|]; simpl; rewrite Hd; apply IH; simpl; done. }
    apply Hinv; reflexivity.
  - intros disp. unfold client_reentrancy_allowed. by rewrite andb_false_r.
  - intros A cache. reflexivity.
Qed.
References

5. Ranvier.Elmish (Mvu.fs) scope-gated dispatch and command ordering

State of an Mvu<'Model, 'Msg> loop (Mvu.fs lines 27–68):

  • mvu_model: current value of the root model signal.
  • mvu_disposed: set to true when the constructing scope's onCleanup runs.
  • mvu_trace: sequence of (observed_model, cmd_id) pairs recording the model value visible to each executed command.
Record mvu_state := {
  mvu_model : Z;
  mvu_disposed : bool;
  mvu_trace : list (Z * nat);
}.
References

Uses

  • bool
  • list
  • nat
  • Z

A command in Mvu.Run (Mvu.fs lines 60–65): inspects the current mvu_state (observing mvu_model after the model write) and may synchronously dispatch or dispose the owning scope.

Definition mvu_cmd := mvu_state -> mvu_state.
References

Mvu.Run (Mvu.fs lines 60–65): while not disposed && not rest.IsEmpty do rest.Head dispatch; rest <- rest.Tail.

Fixpoint mvu_run_cmds (cmds : list mvu_cmd) (st : mvu_state) : mvu_state :=
  match cmds with
  | [] => st
  | c :: rest =>
      if mvu_disposed st then st
      else mvu_run_cmds rest (c st)
  end.
References

Mvu.Apply (Mvu.fs lines 38–46): if not disposed, computes (next_model, cmds) := step msg (mvu_model st), writes mvu_model := next_model, and then runs mvu_run_cmds cmds.

Definition mvu_apply (step : nat -> Z -> Z * list mvu_cmd) (msg : nat) (st : mvu_state) : mvu_state :=
  if mvu_disposed st then st
  else
    let (next_model, cmds) := step msg (mvu_model st) in
    let st_written := {| mvu_model := next_model;
                         mvu_disposed := false;
                         mvu_trace := mvu_trace st |} in
    mvu_run_cmds cmds st_written.
References
✓ No axioms

Once the constructing scope is torn down (mvu_disposed = true), mvu_apply drops every message and mvu_run_cmds skips all remaining commands.

Proves the scope-bound lifetime contract of Ranvier.Elmish (Mvu.fs lines 17–20, 38–46, 63–65):

  • When mvu_disposed st = true, mvu_apply step msg st = st and mvu_run_cmds cmds st = st.
  • If a command c tears down the owning scope (mvu_disposed (c st) = true), mvu_run_cmds (c :: rest) st runs c and immediately halts without executing any command in rest.

Arguments

step : nat -> Z -> Z * list mvu_cmd
the MVU update / step function.
msg : nat
the dispatched message.
cmds : list mvu_cmd
a command list.
a command that disposes the owning scope.
rest : list mvu_cmd
the remaining commands after c.
the Mvu state.
Theorem mvu_disposed_drops_dispatch
    (step : nat -> Z -> Z * list mvu_cmd) (msg : nat)
    (cmds : list mvu_cmd) (c : mvu_cmd) (rest : list mvu_cmd) (st : mvu_state) :
  (mvu_disposed st = true ->
   mvu_apply step msg st = st /\ mvu_run_cmds cmds st = st) /\
  (mvu_disposed st = false ->
   mvu_disposed (c st) = true ->
   mvu_run_cmds (c :: rest) st = c st).

Arguments

step : nat -> Z -> Z * list mvu_cmd
the MVU update / step function.
msg : nat
the dispatched message.
cmds : list mvu_cmd
a command list.
a command that disposes the owning scope.
rest : list mvu_cmd
the remaining commands after c.
the Mvu state.
Qed
Proof.
  split.
  - intros Hdisp. split.
    + unfold mvu_apply. by rewrite Hdisp.
    + destruct cmds as [|c0 cs]; simpl; [done|by rewrite Hdisp].
  - intros Hlive Hc_disp. simpl.
    rewrite Hlive.
    destruct rest as [|r rs]; simpl; [done|by rewrite Hc_disp].
Qed.
References

An observational command obs_cmd cid that records (mvu_model st, cid) into mvu_trace.

Definition obs_cmd (cid : nat) (st : mvu_state) : mvu_state :=
  {| mvu_model := mvu_model st;
     mvu_disposed := mvu_disposed st;
     mvu_trace := mvu_trace st ++ [(mvu_model st, cid)] |}.
References
✓ No axioms

mvu_apply writes the updated model before running commands (root.Value <- model; this.Run commands), so every command observes the post-update model in list order.

Proves the command-ordering contract of Ranvier.Elmish (Mvu.fs lines 43–45, 62–65, 131–132): when mvu_disposed st = false and step msg (mvu_model st) returns (next_model, [obs_cmd c1; obs_cmd c2]), mvu_apply updates mvu_model to next_model first and executes obs_cmd c1 then obs_cmd c2 against next_model.

Arguments

step : nat -> Z -> Z * list mvu_cmd
the MVU step function.
msg : nat
the dispatched message.
next_model : Z
the new model returned by step.
c1 : nat
the first command identifier.
c2 : nat
the second command identifier.
the live Mvu state before Dispatch.
Theorem mvu_apply_writes_before_commands
    (step : nat -> Z -> Z * list mvu_cmd) (msg : nat) (next_model : Z) (c1 c2 : nat) (st : mvu_state) :
  mvu_disposed st = false ->
  step msg (mvu_model st) = (next_model, [obs_cmd c1; obs_cmd c2]) ->
  let st' := mvu_apply step msg st in
  mvu_model st' = next_model /\
  mvu_trace st' = mvu_trace st ++ [(next_model, c1); (next_model, c2)].

Arguments

step : nat -> Z -> Z * list mvu_cmd
the MVU step function.
msg : nat
the dispatched message.
next_model : Z
the new model returned by step.
c1 : nat
the first command identifier.
c2 : nat
the second command identifier.
the live Mvu state before Dispatch.
Qed
Proof.
  intros Hlive Hstep. simpl.
  unfold mvu_apply. rewrite Hlive, Hstep. simpl.
  unfold obs_cmd. simpl.
  rewrite <- app_assoc. simpl.
  split; reflexivity.
Qed.
References

6. Elmish untracked/unjournaled bypass, lazy gate, inline staging, QueryKey, and linked leases

Record arrive_env := {
  ae_tracking : bool;
  ae_host_set : bool;
}.
References

Uses

  • bool
Definition arrive_run_untracked (e : arrive_env) (apply : bool -> Z) : Z * arrive_env :=
  if ae_tracking e then
    let _e_inner := {| ae_tracking := false; ae_host_set := true |} in
    (apply false, {| ae_tracking := true; ae_host_set := ae_host_set e |})
  else
    (apply false, e).
References
Definition arrive_fast (e : arrive_env) (apply : bool -> Z) : Z * arrive_env :=
  if ae_tracking e then arrive_run_untracked e apply
  else (apply false, e).
References
Inductive cmd_work :=
  | WorkNone
  | WorkJournaled.
References
Definition run_cmds_journaled_spec (has_journal : bool) (cmds : list mvu_cmd) (st : mvu_state)
    : mvu_state * cmd_work :=
  if has_journal then (mvu_run_cmds cmds st, WorkJournaled)
  else (mvu_run_cmds cmds st, WorkNone).
References
Definition run_cmds_opt (has_journal : bool) (cmds : list mvu_cmd) (st : mvu_state)
    : mvu_state * cmd_work :=
  if negb has_journal then (mvu_run_cmds cmds st, WorkNone)
  else (mvu_run_cmds cmds st, WorkJournaled).
References
✓ No axioms

Mvu.Arrive bypassing RunUntracked when graph.IsTracking () = false and Mvu.RunCommands skipping JournalWork when graph.Options.Journal.IsNone agree identically with the full untracked and journaled paths.

Proves the Mvu.fs hot-path bypasses:

  • For any tracking environment e and callback apply, arrive_fast e apply = arrive_run_untracked e apply, and when ae_tracking e = false it returns (apply false, e) directly without touching host scope state.
  • For any has_journal flag, command list cmds, and Mvu state st, run_cmds_opt agrees with run_cmds_journaled_spec while emitting WorkNone when has_journal = false.

Arguments

the tracking environment at dispatch arrival.
apply : bool -> Z
the message application function parameterized by whether tracking is active.
has_journal : bool
whether graph.Options.Journal.IsSome.
cmds : list mvu_cmd
the returned Elmish command list.
the initial Mvu state.
Theorem mvu_untracked_bypass_and_direct_cmd_eq
    (e : arrive_env) (apply : bool -> Z) (has_journal : bool) (cmds : list mvu_cmd) (st : mvu_state) :
  arrive_fast e apply = arrive_run_untracked e apply /\
  (ae_tracking e = false -> arrive_fast e apply = (apply false, e)) /\
  run_cmds_opt has_journal cmds st = run_cmds_journaled_spec has_journal cmds st /\
  run_cmds_opt false cmds st = (mvu_run_cmds cmds st, WorkNone).

Arguments

the tracking environment at dispatch arrival.
apply : bool -> Z
the message application function parameterized by whether tracking is active.
has_journal : bool
whether graph.Options.Journal.IsSome.
cmds : list mvu_cmd
the returned Elmish command list.
the initial Mvu state.
Qed
Proof.
  split_and!.
  - unfold arrive_fast, arrive_run_untracked. destruct (ae_tracking e); reflexivity.
  - intros Hnt. unfold arrive_fast. rewrite Hnt. reflexivity.
  - unfold run_cmds_opt, run_cmds_journaled_spec. destruct has_journal; reflexivity.
  - reflexivity.
Qed.
References
Inductive gate_state :=
  | GatePending
  | GateSettled (v : Z)
  | GateFailed (e : nat).
References

Uses

  • nat
  • Z
Record eager_entry := {
  ee_has_data : bool;
  ee_data : Z;
  ee_error : option nat;
  ee_gate : gate_state;
}.
References

Uses

Record lazy_entry := {
  le_has_data : bool;
  le_data : Z;
  le_error : option nat;
  le_gate : option gate_state;
}.
References

Uses

Definition eager_init : eager_entry :=
  {| ee_has_data := false; ee_data := 0%Z; ee_error := None; ee_gate := GatePending |}.
References
Definition lazy_init : lazy_entry :=
  {| le_has_data := false; le_data := 0%Z; le_error := None; le_gate := None |}.
References
Inductive gate_op :=
  | OpStart
  | OpOk (v : Z)
  | OpErr (e : nat)
  | OpReadValue.
References

Uses

  • nat
  • Z
Definition eval_gate (g : gate_state) : Z + option nat :=
  match g with
  | GatePending => inr None
  | GateSettled v => inl v
  | GateFailed e => inr (Some e)
  end.
References

Uses

3 more
  • nat
  • option
  • Z
Definition step_eager (op : gate_op) (ee : eager_entry) : option (Z + option nat) * eager_entry :=
  match op with
  | OpStart =>
      (None, {| ee_has_data := ee_has_data ee;
                ee_data := ee_data ee;
                ee_error := None;
                ee_gate := if ee_has_data ee then ee_gate ee else GatePending |})
  | OpOk v =>
      (None, {| ee_has_data := true;
                ee_data := v;
                ee_error := None;
                ee_gate := if ee_has_data ee then ee_gate ee else GateSettled v |})
  | OpErr e =>
      (None, {| ee_has_data := ee_has_data ee;
                ee_data := ee_data ee;
                ee_error := Some e;
                ee_gate := if ee_has_data ee then ee_gate ee else GateFailed e |})
  | OpReadValue =>
      let res := if ee_has_data ee then inl (ee_data ee) else eval_gate (ee_gate ee) in
      (Some res, ee)
  end.
References
Definition ensure_gate (le : lazy_entry) : gate_state * lazy_entry :=
  match le_gate le with
  | Some g => (g, le)
  | None =>
      let g := match le_error le with
               | Some e => GateFailed e
               | None => GatePending
               end in
      (g, {| le_has_data := le_has_data le;
             le_data := le_data le;
             le_error := le_error le;
             le_gate := Some g |})
  end.
References
Definition step_lazy (op : gate_op) (le : lazy_entry) : option (Z + option nat) * lazy_entry :=
  match op with
  | OpStart =>
      (None, {| le_has_data := le_has_data le;
                le_data := le_data le;
                le_error := None;
                le_gate := if le_has_data le then le_gate le
                           else match le_gate le with
                                | Some _ => Some GatePending
                                | None => None
                                end |})
  | OpOk v =>
      (None, {| le_has_data := true;
                le_data := v;
                le_error := None;
                le_gate := if le_has_data le then le_gate le
                           else match le_gate le with
                                | Some _ => Some (GateSettled v)
                                | None => None
                                end |})
  | OpErr e =>
      (None, {| le_has_data := le_has_data le;
                le_data := le_data le;
                le_error := Some e;
                le_gate := if le_has_data le then le_gate le
                           else match le_gate le with
                                | Some _ => Some (GateFailed e)
                                | None => None
                                end |})
  | OpReadValue =>
      if le_has_data le then (Some (inl (le_data le)), le)
      else let '(g, le') := ensure_gate le in (Some (eval_gate g), le')
  end.
References
Fixpoint run_eager (ops : list gate_op) (ee : eager_entry)
    : list (option (Z + option nat)) * eager_entry :=
  match ops with
  | [] => ([], ee)
  | op :: rest =>
      let '(r, ee1) := step_eager op ee in
      let '(rs, ee') := run_eager rest ee1 in
      (r :: rs, ee')
  end.
References
Fixpoint run_lazy (ops : list gate_op) (le : lazy_entry)
    : list (option (Z + option nat)) * lazy_entry :=
  match ops with
  | [] => ([], le)
  | op :: rest =>
      let '(r, le1) := step_lazy op le in
      let '(rs, le') := run_lazy rest le1 in
      (r :: rs, le')
  end.
References

Uses

Definition entry_gate_rel (ee : eager_entry) (le : lazy_entry) : Prop :=
  ee_has_data ee = le_has_data le /\
  ee_data ee = le_data le /\
  ee_error ee = le_error le /\
  match le_gate le with
  | Some g => ee_gate ee = g
  | None =>
      ee_has_data ee = false ->
      ee_gate ee = match ee_error ee with
                   | Some e => GateFailed e
                   | None => GatePending
                   end
  end.
References
Fixpoint reads_while_empty (ops : list gate_op) (has_data : bool) : bool :=
  match ops with
  | [] => false
  | OpStart :: rest => reads_while_empty rest has_data
  | OpOk _ :: rest => reads_while_empty rest true
  | OpErr _ :: rest => reads_while_empty rest has_data
  | OpReadValue :: rest => if negb has_data then true else reads_while_empty rest has_data
  end.
References

Uses

2 more
  • negb
  • true
✓ No axioms

Lazy initial-load gate allocation (EnsureGate) simulates eager AsyncSource allocation across every trace of entry operations and leaves le_gate = None whenever .Value is never read while empty.

Proves the lazy gate optimization in QueryEntry<'T> (Entry.fs):

Arguments

ops : list gate_op
the trace of entry operations starting from eager_init and lazy_init.
Theorem lazy_query_gate_refines_eager (ops : list gate_op) :
  (run_lazy ops lazy_init).1 = (run_eager ops eager_init).1 /\
  entry_gate_rel (run_eager ops eager_init).2 (run_lazy ops lazy_init).2 /\
  (reads_while_empty ops false = false -> le_gate (run_lazy ops lazy_init).2 = None).

Arguments

ops : list gate_op
the trace of entry operations starting from eager_init and lazy_init.
Qed
Proof.
  assert (Hsim : forall trace ee le,
    entry_gate_rel ee le ->
    (run_lazy trace le).1 = (run_eager trace ee).1 /\
    entry_gate_rel (run_eager trace ee).2 (run_lazy trace le).2).
  { induction trace as [|op rest IH]; intros ee le Hrel.
    - split; [reflexivity | exact Hrel].
    - assert (Hstep :
        (step_lazy op le).1 = (step_eager op ee).1 /\
        entry_gate_rel (step_eager op ee).2 (step_lazy op le).2).
      { destruct ee as [ehd edata eerr egate], le as [lhd ldata lerr lgate].
        destruct Hrel as [Hd [Hv [He Hg]]]; simpl in *.
        subst lhd ldata lerr.
        destruct op as [|v|e|]; unfold entry_gate_rel, ensure_gate; simpl.
        - destruct ehd, lgate as [g|]; simpl in *;
            split_and!; try reflexivity; try exact Hg; try (intros Hfalse; discriminate Hfalse); try (intros _; reflexivity).
        - destruct ehd, lgate as [g|]; simpl in *;
            split_and!; try reflexivity; try exact Hg; try (intros Hfalse; discriminate Hfalse).
        - destruct ehd, lgate as [g|]; simpl in *;
            split_and!; try reflexivity; try exact Hg; try (intros Hfalse; discriminate Hfalse); try (intros _; reflexivity).
        - destruct ehd, lgate as [g|]; simpl in *.
          + split_and!; try reflexivity; exact Hg.
          + split_and!; try reflexivity; intros Hfalse; discriminate Hfalse.
          + rewrite Hg. split_and!; reflexivity.
          + rewrite (Hg eq_refl). split_and!; reflexivity. }
      destruct Hstep as [Hr Hrel'].
      simpl. destruct (step_lazy op le) as [rl le1] eqn:El.
      destruct (step_eager op ee) as [re ee1] eqn:Ee.
      simpl in Hr, Hrel'.
      specialize (IH ee1 le1 Hrel') as [Hrs Hrel''].
      destruct (run_lazy rest le1) as [rls le2] eqn:Erl.
      destruct (run_eager rest ee1) as [res ee2] eqn:Ere.
      simpl in Hrs, Hrel''.
      simpl. split; [rewrite Hr, Hrs; reflexivity | exact Hrel'']. }
  assert (Hnone : forall trace le,
    le_gate le = None ->
    reads_while_empty trace (le_has_data le) = false ->
    le_gate (run_lazy trace le).2 = None).
  { induction trace as [|op rest IH]; intros [lhd ldata lerr lgate] Hgate Hno; simpl in *.
    - exact Hgate.
    - subst lgate. destruct op as [|v|e|]; simpl in *.
      + destruct lhd; simpl in *;
          [ pose proof (IH {| le_has_data := true; le_data := ldata; le_error := None; le_gate := None |} eq_refl Hno) as Hrec;
            destruct (run_lazy rest _) as [rs le']; exact Hrec
          | pose proof (IH {| le_has_data := false; le_data := ldata; le_error := None; le_gate := None |} eq_refl Hno) as Hrec;
            destruct (run_lazy rest _) as [rs le']; exact Hrec ].
      + destruct lhd; simpl in *;
          [ pose proof (IH {| le_has_data := true; le_data := v; le_error := None; le_gate := None |} eq_refl Hno) as Hrec;
            destruct (run_lazy rest _) as [rs le']; exact Hrec
          | pose proof (IH {| le_has_data := true; le_data := v; le_error := None; le_gate := None |} eq_refl Hno) as Hrec;
            destruct (run_lazy rest _) as [rs le']; exact Hrec ].
      + destruct lhd; simpl in *;
          [ pose proof (IH {| le_has_data := true; le_data := ldata; le_error := Some e; le_gate := None |} eq_refl Hno) as Hrec;
            destruct (run_lazy rest _) as [rs le']; exact Hrec
          | pose proof (IH {| le_has_data := false; le_data := ldata; le_error := Some e; le_gate := None |} eq_refl Hno) as Hrec;
            destruct (run_lazy rest _) as [rs le']; exact Hrec ].
      + destruct lhd; [|discriminate Hno]. simpl in *.
        pose proof (IH {| le_has_data := true; le_data := ldata; le_error := lerr; le_gate := None |} eq_refl Hno) as Hrec.
        destruct (run_lazy rest _) as [rs le']; exact Hrec. }
  assert (Hinit_rel : entry_gate_rel eager_init lazy_init) by (repeat split; reflexivity).
  destruct (Hsim ops eager_init lazy_init Hinit_rel) as [Hout Hfinal].
  split; [exact Hout|].
  split; [exact Hfinal|].
  apply (Hnone ops lazy_init eq_refl).
Qed.
References
Inductive ext_draft_edit :=
  | ExtUpdate (f : Z -> Z)
  | ExtSet (v : Z)
  | ExtInvalidate.
References

Uses

  • Z
Record inline_draft := {
  id_staged : bool;
  id_has_value : bool;
  id_value : Z;
  id_stale : bool;
  id_updated : bool;
}.
References

Uses

  • bool
  • Z
Definition init_inline_draft (has_data : bool) (val : Z) : inline_draft :=
  {| id_staged := true; id_has_value := has_data; id_value := val; id_stale := true; id_updated := false |}.
References
Definition step_inline_draft (e : ext_draft_edit) (d : inline_draft) : inline_draft :=
  match e with
  | ExtUpdate f =>
      if id_has_value d then
        {| id_staged := true; id_has_value := true; id_value := f (id_value d); id_stale := false; id_updated := true |}
      else d
  | ExtSet v =>
      if id_has_value d then
        {| id_staged := true; id_has_value := true; id_value := v; id_stale := false; id_updated := true |}
      else d
  | ExtInvalidate =>
      {| id_staged := true; id_has_value := id_has_value d; id_value := id_value d; id_stale := true; id_updated := id_updated d |}
  end.
References
Fixpoint apply_inline_drafts (es : list ext_draft_edit) (d : inline_draft) : inline_draft :=
  match es with
  | [] => d
  | e :: rest => apply_inline_drafts rest (step_inline_draft e d)
  end.
References
Definition to_model_edit (e : ext_draft_edit) : draft_edit :=
  match e with
  | ExtUpdate f => DraftUpdate f
  | ExtSet v => DraftUpdate (fun _ => v)
  | ExtInvalidate => DraftInvalidate
  end.
References
Definition decode_draft (d : inline_draft) : query_draft_state :=
  {| qd_data := if id_has_value d then Some (id_value d) else None;
     qd_stale := id_stale d;
     qd_updated := id_updated d |}.
References
Definition inline_prepare (has_data : bool) (cur : Z) (eqb : Z -> Z -> bool) (d : inline_draft) : bool :=
  if negb (id_updated d) || negb (id_has_value d) then false
  else if negb has_data then true
  else negb (eqb cur (id_value d)).
References

Uses

1 more
  • Z
Definition model_prepare (initial : option Z) (eqb : Z -> Z -> bool) (d : query_draft_state) : bool :=
  match qd_updated d, initial, qd_data d with
  | true, Some old, Some v => negb (eqb old v)
  | true, None, None => false
  | true, _, _ => true
  | false, _, _ => false
  end.
References

Uses

3 more
  • option
  • true
  • Z
Definition commit_reset_draft (publish : bool) (has_data : bool) (cur : Z) (d : inline_draft)
    : bool * (bool * Z) :=
  let next := if publish && id_has_value d then (true, id_value d) else (has_data, cur) in
  (false, next).
References
✓ No axioms

Unboxed (hasData, data) and per-entry inline draftStaged staging (with DraftSet fusion and pre-batch / rollback reset) refine map-allocated QueryDraft over 'T option for arbitrary edit sequences.

Proves the Entry.fs / Queries.fs inline staging optimization:

  • For any initial (has_data, cur) and arbitrary sequence es of ExtUpdate, ExtSet, and ExtInvalidate edits, decode_draft (apply_inline_drafts es (init_inline_draft has_data cur)) equals apply_draft_edits (map to_model_edit es) (init_draft (if has_data then Some cur else None)).
  • Under any edit sequence es, inline_prepare computes the exact same changed bit as model_prepare.
  • Both successful Publish (publish = true) and rollback ResetDraft (publish = false) clear id_staged to false, while rollback leaves (has_data, cur) unmodified.

Arguments

has_data : bool
whether the entry held a committed value before staging.
cur : Z
the committed value stored in the unboxed data signal when has_data = true.
eqb : Z -> Z -> bool
the graph's sentinel-encoded comparer predicate.
es : list ext_draft_edit
the ordered list of edits targeting this entry.
Theorem unboxed_data_and_inline_draft_refines_staged_map
    (has_data : bool) (cur : Z) (eqb : Z -> Z -> bool) (es : list ext_draft_edit) :
  let initial_opt := if has_data then Some cur else None in
  let final_inline := apply_inline_drafts es (init_inline_draft has_data cur) in
  decode_draft final_inline = apply_draft_edits (map to_model_edit es) (init_draft initial_opt) /\
  inline_prepare has_data cur eqb final_inline = model_prepare initial_opt eqb (decode_draft final_inline) /\
  (commit_reset_draft true has_data cur final_inline).1 = false /\
  commit_reset_draft false has_data cur final_inline = (false, (has_data, cur)).

Arguments

has_data : bool
whether the entry held a committed value before staging.
cur : Z
the committed value stored in the unboxed data signal when has_data = true.
eqb : Z -> Z -> bool
the graph's sentinel-encoded comparer predicate.
es : list ext_draft_edit
the ordered list of edits targeting this entry.
Qed
Proof.
  assert (Hstep : forall edits d,
    decode_draft (apply_inline_drafts edits d) =
    apply_draft_edits (map to_model_edit edits) (decode_draft d) /\
    id_has_value (apply_inline_drafts edits d) = id_has_value d /\
    (id_has_value d = false -> id_updated d = false -> id_updated (apply_inline_drafts edits d) = false)).
  { induction edits as [|e rest IH]; intros d.
    - split; [reflexivity | split; [reflexivity | intros _ Hu; exact Hu]].
    - destruct e as [f|v|]; simpl.
      + destruct (id_has_value d) eqn:Ehv; simpl.
        * destruct (IH {| id_staged := true; id_has_value := true; id_value := f (id_value d); id_stale := false; id_updated := true |})
            as [Hdec [Hh Hupd]].
          split; [exact Hdec | split; [exact Hh | intros Hfalse; discriminate Hfalse]].
        * destruct (IH d) as [Hdec [Hh Hupd]].
          split; [exact Hdec | split; [rewrite Hh, Ehv; reflexivity | intros _ Hu; exact (Hupd Ehv Hu)]].
      + destruct (id_has_value d) eqn:Ehv; simpl.
        * destruct (IH {| id_staged := true; id_has_value := true; id_value := v; id_stale := false; id_updated := true |})
            as [Hdec [Hh Hupd]].
          split; [exact Hdec | split; [exact Hh | intros Hfalse; discriminate Hfalse]].
        * destruct (IH d) as [Hdec [Hh Hupd]].
          split; [exact Hdec | split; [rewrite Hh, Ehv; reflexivity | intros _ Hu; exact (Hupd Ehv Hu)]].
      + destruct (IH {| id_staged := true; id_has_value := id_has_value d; id_value := id_value d; id_stale := true; id_updated := id_updated d |})
          as [Hdec [Hh Hupd]].
        split; [exact Hdec | split; [exact Hh | exact Hupd]]. }
  specialize (Hstep es (init_inline_draft has_data cur)).
  destruct Hstep as [Hdec [Hh Hupd]].
  split_and!.
  - rewrite Hdec. unfold init_inline_draft, decode_draft, init_draft. simpl. reflexivity.
  - unfold inline_prepare, model_prepare, decode_draft. simpl.
    rewrite Hh. destruct has_data eqn:Ehd; simpl.
    + destruct (id_updated (apply_inline_drafts es (init_inline_draft true cur))); reflexivity.
    + rewrite (Hupd eq_refl eq_refl). reflexivity.
  - reflexivity.
  - reflexivity.
Qed.
References
Definition qk_default_eq (eqZ : Z -> Z -> bool) (k1 k2 : option Z) : bool :=
  match k1, k2 with
  | Some a, Some b => eqZ a b
  | None, None => true
  | _, _ => false
  end.
References

Uses

  • None
  • Some
  • bool
  • false
  • option
  • true
  • Z
Definition qk_default_hash (hashZ : Z -> Z) (k : option Z) : Z :=
  match k with
  | Some a => hashZ a
  | None => 0%Z
  end.
References

Uses

  • None
  • Some
  • option
  • Z
Definition session_guard_ok (on_thread disposed_client staging : bool) : bool :=
  on_thread && negb disposed_client && negb staging.
References

Uses

  • bool
  • negb
Definition single_checked_op {A : Type}
    (on_thread disposed_client staging disposed_lease disposed_entry : bool) (op : A) : option A :=
  if session_guard_ok on_thread disposed_client staging && negb disposed_lease && negb disposed_entry
  then Some op
  else None.
References

Uses

Definition double_checked_op {A : Type}
    (on_thread disposed_client staging disposed_lease disposed_entry : bool) (op : A) : option A :=
  if session_guard_ok on_thread disposed_client staging && negb disposed_lease then
    if session_guard_ok on_thread disposed_client staging && negb disposed_entry then Some op
    else None
  else None.
References

Uses

✓ No axioms

QueryKey default-comparer equality/hashing handles nullable and unit (None) keys consistently, and checking QuerySession.Guard once at QueryLease matches double-checked QueryLease + QueryEntry guards.

Proves the Queries.fs QueryKey devirtualization and QuerySession single-guard elimination:

  • Whenever eqZ is reflexive (eqZ x x = true) and hash-compatible (eqZ x y = true -> hashZ x = hashZ y), qk_default_eq eqZ is reflexive on all option Z (including None for unit/null) and preserves qk_default_hash hashZ without invoking a null dereference on None.
  • For all thread, disposal, and staging flags, single_checked_op agrees with double_checked_op.

Arguments

eqZ : Z -> Z -> bool
the default equality predicate on non-null keys.
hashZ : Z -> Z
the default hash function on non-null keys.
k1 : option Z
first wrapped key (None represents () / null).
k2 : option Z
second wrapped key.
Theorem query_key_default_equatable_and_session_guard_eq
    (eqZ : Z -> Z -> bool) (hashZ : Z -> Z) (k1 k2 : option Z) :
  (forall x, eqZ x x = true) ->
  (forall x y, eqZ x y = true -> hashZ x = hashZ y) ->
  qk_default_eq eqZ k1 k1 = true /\
  (qk_default_eq eqZ k1 k2 = true -> qk_default_hash hashZ k1 = qk_default_hash hashZ k2) /\
  forall (A : Type) (on_thread dc st dl de : bool) (op : A),
    single_checked_op on_thread dc st dl de op = double_checked_op on_thread dc st dl de op.

Arguments

eqZ : Z -> Z -> bool
the default equality predicate on non-null keys.
hashZ : Z -> Z
the default hash function on non-null keys.
k1 : option Z
first wrapped key (None represents () / null).
k2 : option Z
second wrapped key.
Qed
Proof.
  intros Hrefl Hhash. split_and!.
  - destruct k1; simpl; [apply Hrefl | reflexivity].
  - destruct k1, k2; simpl; try discriminate; [apply Hhash | intros _; reflexivity].
  - intros A on_thread dc st dl de op.
    unfold single_checked_op, double_checked_op, session_guard_ok.
    destruct on_thread, dc, st, dl, de; reflexivity.
Qed.
References
Inductive await_outcome :=
  | AwaitOk (v : Z)
  | AwaitErr (err : nat)
  | AwaitCanceled.
References

Uses

  • nat
  • Z
Definition await_immediate_decision (err : option nat) (has_data stale : bool) (data_val : Z) : await_outcome :=
  match err with
  | Some e => AwaitErr e
  | None => if has_data && negb stale then AwaitOk data_val else AwaitCanceled
  end.
References

Uses

3 more
  • negb
  • option
  • Z
Definition await_waiter_spec
    (status : fetch_status) (err : option nat) (has_data stale : bool) (data_val : Z)
    : bool * option await_outcome :=
  match status with
  | FsFetching => (true, None)
  | FsIdle => (false, Some (await_immediate_decision err has_data stale data_val))
  end.
References
Definition await_fast_opt
    (status : fetch_status) (err : option nat) (has_data stale : bool) (data_val : Z)
    : bool * option await_outcome :=
  match status with
  | FsFetching => (true, None)
  | FsIdle => (false, Some (await_immediate_decision err has_data stale data_val))
  end.
References
Record linked_lease_state := {
  ll_lease_state : query_lease_state;
  ll_owner_attached : bool;
  ll_waiter_detached : bool;
}.
References
Definition linked_lease_dispose (st : linked_lease_state) : linked_lease_state :=
  {| ll_lease_state := query_lease_dispose (ll_lease_state st);
     ll_owner_attached := false;
     ll_waiter_detached := true |}.
References
✓ No axioms

QueryEntry.AwaitImmediate allocates zero waiters when FetchStatus = FsIdle with identical outcome, QueryAwaiter.TryClaim is idempotent, and OwnerLink-backed QueryLease.Dispose detaches cleanly and decrements refcount at most once.

Proves the Entry.fs / Queries.fs waiter and lease-link optimizations:

Arguments

status : fetch_status
current FetchStatus of the entry.
err : option nat
current Error option in metadata.
has_data : bool
whether data is loaded.
stale : bool
whether cached data is stale.
data_val : Z
cached payload value.
combined lease, owner-link, and waiter-claim state.
k : nat
number of sibling leases remaining.
Theorem waiter_fast_task_and_linked_lease_eq
    (status : fetch_status) (err : option nat) (has_data stale : bool) (data_val : Z)
    (st : linked_lease_state) (k : nat) :
  await_fast_opt status err has_data stale data_val = await_waiter_spec status err has_data stale data_val /\
  fst (await_fast_opt FsIdle err has_data stale data_val) = false /\
  linked_lease_dispose (linked_lease_dispose st) = linked_lease_dispose st /\
  ll_owner_attached (linked_lease_dispose st) = false /\
  ll_waiter_detached (linked_lease_dispose st) = true /\
  (ql_lease_disposed (ll_lease_state st) = false ->
   ql_ref_count (ll_lease_state st) = S k ->
   ql_entry_alive (ll_lease_state st) = true ->
   ql_ref_count (ll_lease_state (linked_lease_dispose st)) = k /\
   ql_entry_alive (ll_lease_state (linked_lease_dispose st)) = bool_decide (0 < k)).

Arguments

status : fetch_status
current FetchStatus of the entry.
err : option nat
current Error option in metadata.
has_data : bool
whether data is loaded.
stale : bool
whether cached data is stale.
data_val : Z
cached payload value.
combined lease, owner-link, and waiter-claim state.
k : nat
number of sibling leases remaining.
Qed
Proof.
  split_and!.
  - reflexivity.
  - reflexivity.
  - unfold linked_lease_dispose. simpl.
    destruct (query_lease_dispose_idempotent_refcount (ll_lease_state st) k) as [Hid _].
    rewrite Hid. reflexivity.
  - reflexivity.
  - reflexivity.
  - intros Hlive Hcnt Halive. simpl.
    destruct (query_lease_dispose_idempotent_refcount (ll_lease_state st) k) as [_ Hdec].
    exact (Hdec Hlive Hcnt Halive).
Qed.
References

7. Wave 6 CSharp, Wire, Mcp, and Dom optimisations

Inductive bound_status := BStNone | BStPending | BStError.
References
Inductive bound_reading :=
  | BRReady (v : Z)
  | BRPending
  | BRFailed (e : nat).
References

Uses

  • nat
  • Z
Definition decode_struct_reading (st : bound_status) (v : Z) (err : option nat) : bound_reading :=
  match st, err with
  | BStNone, _ => BRReady v
  | BStPending, _ => BRPending
  | BStError, Some e => BRFailed e
  | BStError, None => BRFailed 0
  end.
References
Record bound_state := {
  bs_val : Z;
  bs_has : bool;
  bs_loading : bool;
  bs_error : option nat;
}.
References

Uses

  • bool
  • nat
  • option
  • Z
Definition eq_opt_nat (a b : option nat) : bool :=
  match a, b with
  | None, None => true
  | Some x, Some y => Nat.eqb x y
  | _, _ => false
  end.
References

Uses

  • None
  • Some
  • bool
  • false
  • nat
  • option
  • true
  • Nat.eqb
Definition bound_refresh_flags (eqZ : Z -> Z -> bool) (old : bound_state) (r : bound_reading)
    : bool * bool * bool :=
  match r with
  | BRReady v =>
      (negb (bs_has old) || negb (eqZ (bs_val old) v),
       bs_loading old,
       match bs_error old with None => false | Some _ => true end)
  | BRPending =>
      (false,
       negb (bs_loading old),
       match bs_error old with None => false | Some _ => true end)
  | BRFailed e =>
      (false,
       bs_loading old,
       negb (eq_opt_nat (bs_error old) (Some e)))
  end.
References
Definition bound_refresh_alloc (eqZ : Z -> Z -> bool) (old : bound_state) (r : bound_reading)
    : bound_state * (bool * bool * bool) :=
  let '(vc, lc, ec) := bound_refresh_flags eqZ old r in
  let next :=
    match r with
    | BRReady v => {| bs_val := v; bs_has := true; bs_loading := false; bs_error := None |}
    | BRPending => {| bs_val := bs_val old; bs_has := bs_has old; bs_loading := true; bs_error := None |}
    | BRFailed e => {| bs_val := bs_val old; bs_has := bs_has old; bs_loading := false; bs_error := Some e |}
    end in
  (next, (vc, lc, ec)).
References
Definition bound_refresh_reuse (custom_cmp : bool) (eqZ : Z -> Z -> bool) (old : bound_state) (r : bound_reading)
    : bound_state * (bool * bool * bool) :=
  let '(vc, lc, ec) := bound_refresh_flags eqZ old r in
  let next :=
    match r with
    | BRReady v =>
        if vc || lc || ec || custom_cmp then
          {| bs_val := v; bs_has := true; bs_loading := false; bs_error := None |}
        else old
    | BRPending =>
        if lc || ec then
          {| bs_val := bs_val old; bs_has := bs_has old; bs_loading := true; bs_error := None |}
        else old
    | BRFailed e =>
        if lc || ec then
          {| bs_val := bs_val old; bs_has := bs_has old; bs_loading := false; bs_error := Some e |}
        else old
    end in
  (next, (vc, lc, ec)).
References
Definition direct_signal_dispatch (on_thread : bool) (inbox : list Z) (v : Z) : option Z * list Z :=
  if on_thread then (Some v, inbox) else (None, inbox ++ [v]).
References

Uses

  • None
  • Some
  • bool
  • list
  • option
  • Z
Definition queued_signal_dispatch (on_thread : bool) (inbox : list Z) (v : Z) : option Z * list Z :=
  if on_thread then (Some v, inbox) else (None, inbox ++ [v]).
References

Uses

  • None
  • Some
  • bool
  • list
  • option
  • Z
✓ No axioms

BoundValue / BoundSignal struct reads and unchanged-BoundState reuse match fresh allocations under default equality, and BoundSignal.set_Value direct on-thread dispatch matches Graph.Dispatch.

Proves the Memo.TryReadStruct, BoundValue/BoundSignal unchanged-state reuse, and BoundSignal.set_Value optimizations (Core.fs, Bindings.fs):

  • decode_struct_reading faithfully decodes TryReadStruct (Status * 'T * exn) tuples into BRReady, BRPending, and BRFailed.
  • Whenever eqZ respects strict equality when custom_cmp = false (forall a b, eqZ a b = true -> a = b), bound_refresh_reuse false eqZ old r = bound_refresh_alloc eqZ old r across all prior states old and readings r, and for custom_cmp = true both also agree unconditionally (bound_refresh_reuse true eqZ old r = bound_refresh_alloc eqZ old r).
  • direct_signal_dispatch on_thread inbox v = queued_signal_dispatch on_thread inbox v.

Arguments

eqZ : Z -> Z -> bool
equality predicate on values.
the previously published bound_state snapshot.
the current Memo / Signal reading.
custom_cmp : bool
whether a custom IEqualityComparer was configured on the graph.
on_thread : bool
whether the caller is currently on the graph thread.
inbox : list Z
pending cross-thread work queue before the write.
v : Z
signal value written via BoundSignal.Value <- v.
Theorem bound_slot_inplace_refresh_and_direct_dispatch_eq
    (eqZ : Z -> Z -> bool) (old : bound_state) (r : bound_reading)
    (custom_cmp on_thread : bool) (inbox : list Z) (v : Z) :
  (custom_cmp = false -> forall a b, eqZ a b = true -> a = b) ->
  bound_refresh_reuse custom_cmp eqZ old r = bound_refresh_alloc eqZ old r /\
  direct_signal_dispatch on_thread inbox v = queued_signal_dispatch on_thread inbox v /\
  decode_struct_reading BStNone v None = BRReady v /\
  decode_struct_reading BStPending v None = BRPending /\
  forall err, decode_struct_reading BStError v (Some err) = BRFailed err.

Arguments

eqZ : Z -> Z -> bool
equality predicate on values.
the previously published bound_state snapshot.
the current Memo / Signal reading.
custom_cmp : bool
whether a custom IEqualityComparer was configured on the graph.
on_thread : bool
whether the caller is currently on the graph thread.
inbox : list Z
pending cross-thread work queue before the write.
v : Z
signal value written via BoundSignal.Value <- v.
Qed
Proof.
  intros Hdef. split_and!.
  - destruct old as [ov ohas oload oerr], r as [rv | | re], custom_cmp;
      unfold bound_refresh_reuse, bound_refresh_alloc, bound_refresh_flags; simpl.
    + rewrite orb_true_r. reflexivity.
    + destruct ohas eqn:Ehas; simpl; [|reflexivity].
      destruct (eqZ ov rv) eqn:Eeq; simpl; [|reflexivity].
      destruct oload eqn:Eload; simpl; [reflexivity|].
      destruct oerr as [e|] eqn:Eerr; simpl; [reflexivity|].
      rewrite (Hdef eq_refl ov rv Eeq). reflexivity.
    + destruct oload; destruct oerr; reflexivity.
    + destruct oload; destruct oerr; reflexivity.
    + destruct oload; simpl; [reflexivity|].
      destruct oerr as [e|]; simpl; [|reflexivity].
      destruct (Nat.eqb e re) eqn:Een; simpl; [rewrite (proj1 (Nat.eqb_eq e re) Een); reflexivity | reflexivity].
    + destruct oload; simpl; [reflexivity|].
      destruct oerr as [e|]; simpl; [|reflexivity].
      destruct (Nat.eqb e re) eqn:Een; simpl; [rewrite (proj1 (Nat.eqb_eq e re) Een); reflexivity | reflexivity].
  - reflexivity.
  - reflexivity.
  - reflexivity.
  - intros err. reflexivity.
Qed.
References
Record rc_state := {
  rc_running : nat;
  rc_error : option nat;
  rc_journaled : bool;
  rc_flights : nat;
}.
References

Uses

  • bool
  • nat
  • option
Inductive rc_task_outcome :=
  | RcCompleted
  | RcFaulted (e : nat)
  | RcCanceled.
References

Uses

  • nat
Global Instance rc_task_outcome_eq_dec : EqDecision rc_task_outcome.
Defined
Proof. solve_decision. Defined.
References

Uses

Definition rc_sync_with_cts (failure : option nat) (st : rc_state) : rc_state * rc_task_outcome :=
  let r1 := S (rc_running st) in
  let r2 := r1 - 1 in
  let err' := failure in
  let task := match failure with Some e => RcFaulted e | None => RcCompleted end in
  ({| rc_running := r2; rc_error := err'; rc_journaled := rc_journaled st; rc_flights := rc_flights st |}, task).
References
Definition rc_sync_direct (failure : option nat) (st : rc_state) : rc_state * rc_task_outcome :=
  let r1 := S (rc_running st) in
  let write_err := negb (eq_opt_nat (rc_error st) failure) || rc_journaled st in
  let err' := if write_err then failure else rc_error st in
  let task := match failure with Some e => RcFaulted e | None => RcCompleted end in
  ({| rc_running := r1 - 1; rc_error := err'; rc_journaled := rc_journaled st; rc_flights := rc_flights st |}, task).
References
Definition rc_onthread_task (need_task : bool) (out : rc_task_outcome) : rc_task_outcome :=
  if need_task then out else RcCompleted.
References
Definition notify_delivered (has_changes has_handlers : bool) (notes : list nat) : bool * list nat :=
  if has_changes && has_handlers then (true, notes) else (false, []).
References

Uses

  • bool
  • false
  • list
  • nat
  • true
Definition notify_eager (has_changes has_handlers : bool) (notes : list nat) : list nat :=
  if has_changes then (if has_handlers then notes else []) else [].
References

Uses

  • bool
  • list
  • nat
✓ No axioms

Synchronous ReactiveCommand execution without CancellationTokenSource preserves exact running-count, error, and task-outcome semantics, and skipping RunUntracked without handlers emits identical events.

Proves the ReactiveCommand and ReactiveBindings.notify optimizations (Bindings.fs):

  • rc_sync_direct failure st produces the exact same post-execution rc_state (including restoring rc_running to rc_running st, updating rc_error to failure, and leaving rc_flights unchanged) and rc_task_outcome as rc_sync_with_cts failure st.
  • rc_onthread_task need_task out matches immediate completed task return when need_task = false and exact faulted/canceled propagation when need_task = true.
  • notify_delivered skips RunUntracked (fst = false) whenever has_handlers = false and produces the exact same delivered notifications snd as notify_eager.

Arguments

failure : option nat
optional exception raised by synchronous execution.
initial ReactiveCommand state before execution.
need_task : bool
whether the caller (ExecuteAsync vs Execute) observes the returned task.
completed outcome produced on the graph thread.
has_changes : bool
whether any slot or command state changed during notify.
has_handlers : bool
whether any PropertyChanged, ErrorsChanged, or CanExecuteChanged listener is subscribed.
notes : list nat
non-empty notification payload emitted when changes exist.
Theorem reactive_command_inline_exec_and_lazy_notify_eq
    (failure : option nat) (st : rc_state)
    (need_task has_changes has_handlers : bool) (out : rc_task_outcome) (notes : list nat) :
  rc_sync_direct failure st = rc_sync_with_cts failure st /\
  rc_running (rc_sync_direct failure st).1 = rc_running st /\
  (rc_onthread_task need_task out = if need_task then out else RcCompleted) /\
  (notify_delivered has_changes has_handlers notes).2 = notify_eager has_changes has_handlers notes /\
  (has_handlers = false -> (notify_delivered has_changes false notes).1 = false).

Arguments

failure : option nat
optional exception raised by synchronous execution.
initial ReactiveCommand state before execution.
need_task : bool
whether the caller (ExecuteAsync vs Execute) observes the returned task.
completed outcome produced on the graph thread.
has_changes : bool
whether any slot or command state changed during notify.
has_handlers : bool
whether any PropertyChanged, ErrorsChanged, or CanExecuteChanged listener is subscribed.
notes : list nat
non-empty notification payload emitted when changes exist.
Qed
Proof.
  split_and!.
  - unfold rc_sync_direct, rc_sync_with_cts.
    destruct (rc_error st) as [e1|] eqn:E1, failure as [e2|]; simpl.
    + destruct (Nat.eqb e1 e2) eqn:Eeq; simpl;
        [rewrite (proj1 (Nat.eqb_eq e1 e2) Eeq); destruct (rc_journaled st); reflexivity | reflexivity].
    + reflexivity.
    + reflexivity.
    + destruct (rc_journaled st); reflexivity.
  - unfold rc_sync_direct. simpl. lia.
  - reflexivity.
  - unfold notify_delivered, notify_eager. destruct has_changes, has_handlers; reflexivity.
  - intros _. unfold notify_delivered. destruct has_changes; reflexivity.
Qed.
References
Fixpoint any_pending_loop (is_pending : nat -> bool) (xs : list nat) : bool * list nat :=
  match xs with
  | [] => (false, [])
  | x :: rest =>
      if is_pending x then (true, [x])
      else
        let '(res, vis) := any_pending_loop is_pending rest in
        (res, x :: vis)
  end.
References

Uses

  • bool
  • false
  • list
  • nat
  • true
Definition exposure_rev_diff (pairs : list (nat * Z * Z)) : list nat :=
  fold_right (fun '(nm, oldv, newv) acc => if Z.eqb oldv newv then acc else nm :: acc) [] pairs.
References

Uses

  • list
  • nat
  • Z
  • fold_right
  • Z.eqb
Definition exposure_filter_diff (pairs : list (nat * Z * Z)) : list nat :=
  map (fun '(nm, _, _) => nm) (List.filter (fun '(_, oldv, newv) => negb (Z.eqb oldv newv)) pairs).
References

Uses

  • list
  • nat
  • negb
  • map
  • Z
  • filter
  • Z.eqb
Definition modifier_key_names : list string :=
  [ "Shift"; "Control"; "Alt"; "Meta"; "AltGraph";
    "CapsLock"; "Fn"; "FnLock"; "Hyper"; "Super";
    "Symbol"; "SymbolLock"; "NumLock"; "ScrollLock"; "OS" ]%string.
References

Uses

  • list
  • string
Definition is_modifier_key_match (k : string) : bool :=
  match k with
  | "Shift"%string | "Control"%string | "Alt"%string | "Meta"%string | "AltGraph"%string
  | "CapsLock"%string | "Fn"%string | "FnLock"%string | "Hyper"%string | "Super"%string
  | "Symbol"%string | "SymbolLock"%string | "NumLock"%string | "ScrollLock"%string | "OS"%string => true
  | _ => false
  end.
References

Uses

  • bool
  • false
  • true
  • string
Definition dispatch_dom_observers {A : Type} (obs : list A) : list A :=
  if Nat.eqb (length obs) 0 then [] else obs.
References

Uses

  • length
  • list
  • Nat.eqb
✓ No axioms

Reactive.AnyPending while loop short-circuits cleanly, Exposure.publish backwards scan preserves registration order with zero empty-diff changes, InputState.isModifierKey matches the 15 DOM modifier names, and empty-observer DOM fast-paths match full iteration.

Proves the loop, publishing, and observer-guard optimizations in Reactive.fs, Exposure.fs, and Ranvier.Dom:

  • any_pending_loop is_pending xs returns (existsb is_pending xs, vis) where vis is a prefix of xs that visits xs strictly in order up to the first pending node (all prior nodes non-pending, stopping immediately at true).
  • exposure_rev_diff pairs matches exposure_filter_diff pairs and is [] iff every entry text equals its previous text (Forall (fun '(_, a, b) => a = b) pairs).
  • is_modifier_key_match k = existsb (String.eqb k) modifier_key_names for every string k.
  • dispatch_dom_observers obs = obs for every observer snapshot obs.

Arguments

is_pending : nat -> bool
node pending-status predicate.
xs : list nat
registered source node ids passed to AnyPending.
pairs : list (nat * Z * Z)
triples (entry_id, old_text, new_text) in registration order.
k : string
keyboard key string inspected by InputState.
obs : list A
subscriber callback list in Ranvier.Dom.
Theorem any_pending_loop_and_unsubscribed_publish_eq
    (is_pending : nat -> bool) (xs : list nat) (pairs : list (nat * Z * Z))
    (k : string) {A : Type} (obs : list A) :
  (any_pending_loop is_pending xs).1 = existsb is_pending xs /\
  (exists tail,
     (any_pending_loop is_pending xs).2 ++ tail = xs /\
     ((any_pending_loop is_pending xs).1 = false ->
      (any_pending_loop is_pending xs).2 = xs /\ Forall (fun x => is_pending x = false) xs)) /\
  exposure_rev_diff pairs = exposure_filter_diff pairs /\
  (exposure_rev_diff pairs = [] <-> Forall (fun '(_, a, b) => a = b) pairs) /\
  is_modifier_key_match k = existsb (String.eqb k) modifier_key_names /\
  dispatch_dom_observers obs = obs.

Arguments

is_pending : nat -> bool
node pending-status predicate.
xs : list nat
registered source node ids passed to AnyPending.
pairs : list (nat * Z * Z)
triples (entry_id, old_text, new_text) in registration order.
k : string
keyboard key string inspected by InputState.
obs : list A
subscriber callback list in Ranvier.Dom.
Qed
Proof.
  split_and!.
  - induction xs as [|x rest IH]; simpl.
    + reflexivity.
    + destruct (is_pending x); simpl; [reflexivity|].
      destruct (any_pending_loop is_pending rest) as [res vis] eqn:Eloop.
      simpl in *. exact IH.
  - induction xs as [|x rest IH]; simpl.
    + exists []. split; [reflexivity | intros _; split; [reflexivity | constructor]].
    + destruct (is_pending x) eqn:Hx; simpl.
      * exists rest. split; [reflexivity | intros Hfalse; discriminate Hfalse].
      * destruct (any_pending_loop is_pending rest) as [res vis] eqn:Eloop.
        destruct IH as [tail [Happ Hfalse]]. simpl in *.
        exists tail. split.
        -- rewrite <- Happ. reflexivity.
        -- intros Hres. destruct (Hfalse Hres) as [Hvis Hall].
           subst vis. split; [reflexivity | constructor; assumption].
  - unfold exposure_rev_diff, exposure_filter_diff.
    induction pairs as [|[[nm oldv] newv] rest IH]; simpl; [reflexivity|].
    destruct (Z.eqb oldv newv); simpl; rewrite IH; reflexivity.
  - split.
    + unfold exposure_rev_diff.
      induction pairs as [|[[nm oldv] newv] rest IH]; simpl; [intros _; constructor|].
      destruct (Z.eqb oldv newv) eqn:Eeq.
      * intros Hnil. constructor; [exact (proj1 (Z.eqb_eq oldv newv) Eeq) | exact (IH Hnil)].
      * intros Hcons. discriminate Hcons.
    + unfold exposure_rev_diff.
      induction pairs as [|[[nm oldv] newv] rest IH]; intros Hall; simpl; [reflexivity|].
      inversion Hall as [|? ? Heq Hrest]; simpl in Heq.
      rewrite (proj2 (Z.eqb_eq oldv newv) Heq). exact (IH Hrest).
  - unfold is_modifier_key_match, modifier_key_names.
    repeat (simpl; try reflexivity;
      lazymatch goal with
      | |- (match ?x with _ => _ end = _) =>
          destruct x
      end).
  - unfold dispatch_dom_observers. destruct obs; reflexivity.
Qed.
References
Definition is_high_surr (c : Z) : bool :=
  bool_decide (55296 <= c /\ c <= 56319)%Z.
References

Uses

  • bool
  • Z
  • bool_decide
Definition is_low_surr (c : Z) : bool :=
  bool_decide (56320 <= c /\ c <= 57343)%Z.
References

Uses

  • bool
  • Z
  • bool_decide
Definition is_any_surr (c : Z) : bool :=
  is_high_surr c || is_low_surr c.
References
Fixpoint lone_surr_from (xs : list Z) (idx : nat) : option nat :=
  match xs with
  | [] => None
  | c :: rest =>
      if is_high_surr c then
        match rest with
        | d :: rest' => if is_low_surr d then lone_surr_from rest' (idx + 2) else Some idx
        | [] => Some idx
        end
      else if is_low_surr c then Some idx
      else lone_surr_from rest (S idx)
  end.
References

Uses

1 more
  • Z
Fixpoint prescan_plain_loop (in_str : bool) (pending : nat) (xs : list Z) : option (bool * nat) :=
  match xs with
  | [] => Some (in_str, pending)
  | c :: rest =>
      if in_str then
        if Z.eqb c 92%Z then None
        else if Z.eqb c 34%Z then
          if Nat.eqb pending 0 then prescan_plain_loop false 0 rest else None
        else
          if negb (Nat.eqb pending 0) then
            if is_low_surr c then prescan_plain_loop true 0 rest else None
          else if is_high_surr c then prescan_plain_loop true 1 rest
          else if is_low_surr c then None
          else prescan_plain_loop true 0 rest
      else None
  end.
References

Uses

6 more
  • negb
  • option
  • true
  • Z
  • Nat.eqb
  • Z.eqb
✓ No axioms

Skipping any surrogate-free prefix in loneSurrogate, validating single char scalars in-place, and skipping plain BMP runs inside Prescan.check strings preserve exact scanner results.

Proves the UTF-16 scalar validation and JSON string pre-scan optimizations (Helpers.fs, Prescan.fs):

  • For any surrogate-free prefix pref (Forall (fun c => is_any_surr c = false) pref) and any suffix suf, lone_surr_from (pref ++ suf) idx = lone_surr_from suf (idx + length pref) (and None when suf = []).
  • For a single UTF-16 code unit c (encodeChar), lone_surr_from [c] 0 = (if is_any_surr c then Some 0 else None).
  • Whenever pending = 0 inside a JSON string, skipping a contiguous run plain of unescaped non-quote characters below 0xD800 (55296%Z) leaves prescan_plain_loop true 0 (plain ++ suf) = prescan_plain_loop true 0 suf.

Arguments

pref : list Z
surrogate-free leading slice skipped by SIMD IndexOfAnyInRange.
suf : list Z
trailing UTF-16 code units starting at the first surrogate candidate.
idx : nat
starting index accumulator.
c : Z
single UTF-16 code unit passed to encodeChar.
plain : list Z
contiguous plain BMP characters inside a string literal (c <> 92, c <> 34, c < 55296).
Theorem wire_surrogate_prefix_skip_and_char_scalar_eq
    (pref suf plain : list Z) (idx : nat) (c : Z) :
  (Forall (fun u => is_any_surr u = false) pref ->
   lone_surr_from (pref ++ suf) idx = lone_surr_from suf (idx + length pref)) /\
  (Forall (fun u => is_any_surr u = false) pref ->
   lone_surr_from pref idx = None) /\
  lone_surr_from [c] 0 = (if is_any_surr c then Some 0 else None) /\
  (Forall (fun u => u <> 92%Z /\ u <> 34%Z /\ (u < 55296)%Z) plain ->
   prescan_plain_loop true 0 (plain ++ suf) = prescan_plain_loop true 0 suf).

Arguments

pref : list Z
surrogate-free leading slice skipped by SIMD IndexOfAnyInRange.
suf : list Z
trailing UTF-16 code units starting at the first surrogate candidate.
idx : nat
starting index accumulator.
c : Z
single UTF-16 code unit passed to encodeChar.
plain : list Z
contiguous plain BMP characters inside a string literal (c <> 92, c <> 34, c < 55296).
Qed
Proof.
  split_and!.
  - revert idx. induction pref as [|u rest IH]; intros i Hall; simpl.
    + rewrite Nat.add_0_r. reflexivity.
    + inversion Hall as [|? ? Hu Hrest]; subst.
      unfold is_any_surr in Hu. apply orb_false_iff in Hu as [Hh Hl].
      rewrite Hh, Hl. rewrite (IH (S i) Hrest). rewrite Nat.add_succ_r. reflexivity.
  - revert idx. induction pref as [|u rest IH]; intros i Hall; simpl; [reflexivity|].
    inversion Hall as [|? ? Hu Hrest]; subst.
    unfold is_any_surr in Hu. apply orb_false_iff in Hu as [Hh Hl].
    rewrite Hh, Hl. exact (IH (S i) Hrest).
  - unfold is_any_surr. simpl. destruct (is_high_surr c), (is_low_surr c); reflexivity.
  - induction plain as [|u rest IH]; intros Hall; simpl; [reflexivity|].
    inversion Hall as [|? ? [Hbs [Hq Hbmp]] Hrest]; subst.
    rewrite (proj2 (Z.eqb_neq u 92%Z) Hbs).
    rewrite (proj2 (Z.eqb_neq u 34%Z) Hq).
    assert (Hh : is_high_surr u = false)
      by (unfold is_high_surr; apply bool_decide_eq_false_2; lia).
    assert (Hl : is_low_surr u = false)
      by (unfold is_low_surr; apply bool_decide_eq_false_2; lia).
    rewrite Hh, Hl. simpl. exact (IH Hrest).
Qed.
References

Uses

13 more
  • false
  • length
  • list
  • nat
  • true
  • proj2
  • Forall
  • Z
  • Nat.add_0_r
  • Nat.add_succ_r
  • orb_false_iff
  • Z.eqb_neq
  • bool_decide_eq_false_2
Fixpoint strip_leading_zeros (xs : list Z) : list Z :=
  match xs with
  | [] => []
  | c :: rest => if Z.eqb c 48%Z then strip_leading_zeros rest else c :: rest
  end.
References

Uses

  • list
  • Z
  • Z.eqb
Definition mantissa_digits (xs : list Z) : list Z :=
  strip_leading_zeros (List.filter (fun c => negb (Z.eqb c 46%Z)) xs).
References

Uses

Definition z_cmp (x y : Z) : Z :=
  match Z.compare x y with
  | Lt => (-1)%Z
  | Eq => 0%Z
  | Gt => 1%Z
  end.
References

Uses

  • Eq
  • Gt
  • Lt
  • Z
  • Z.compare
Fixpoint list_lex_cmp (a b : list Z) : Z :=
  match a, b with
  | x :: xs, y :: ys =>
      let c := z_cmp x y in
      if Z.eqb c 0%Z then list_lex_cmp xs ys else c
  | [], _ :: _ => (-1)%Z
  | _ :: _, [] => 1%Z
  | [], [] => 0%Z
  end.
References

Uses

Definition step_mantissa_scan (max_digits : list Z) (st : nat * Z) (c : Z) : nat * Z :=
  let '(sig_len, cmp) := st in
  if Z.eqb c 46%Z || (Nat.eqb sig_len 0 && Z.eqb c 48%Z) then st
  else
    let cmp' :=
      if (sig_len <? length max_digits) && Z.eqb cmp 0%Z
      then z_cmp c (nth sig_len max_digits 0%Z)
      else cmp in
    (S sig_len, cmp').
References

Uses

  • z_cmp
  • S
  • length
  • list
  • nat
  • nth
  • Z
  • Nat.eqb
1 more
  • Z.eqb
Definition scan_mantissa (max_digits xs : list Z) : nat * Z :=
  foldl (step_mantissa_scan max_digits) (0, 0%Z) xs.
References

Uses

Definition ref_fits_mantissa (max_digits ds : list Z) : bool :=
  (length ds <? length max_digits) ||
  ((length ds =? length max_digits) && (list_lex_cmp ds max_digits <=? 0)%Z).
References

Uses

Definition scan_fits_mantissa (max_digits xs : list Z) : bool :=
  let '(sig_len, cmp) := scan_mantissa max_digits xs in
  (sig_len <? length max_digits) || ((sig_len =? length max_digits) && (cmp <=? 0)%Z).
References

Uses

✓ No axioms

inPropertyOrder without array-index keys is the identity, Dictionary.Count increase characterizes first-time member insertion, and fitsDecimal in-place mantissa scanning matches string-allocating normalization and ordinal comparison.

Proves the Helpers.fs and Codecs.fs zero-allocation algorithms:

  • Whenever is_idx is false on all elements of xs, filter is_idx xs ++ filter (negb ∘ is_idx) xs = xs.
  • For any finite dictionary m : gmap nat Z, inserting (k, v) strictly increases size iff m !! k = None.
  • On any digit/dot list xs, scan_mantissa max_digits xs computes (length (mantissa_digits xs), cmp) such that scan_fits_mantissa max_digits xs = ref_fits_mantissa max_digits (mantissa_digits xs) with zero intermediate list or string allocations.

Arguments

is_idx : Z -> bool
array-index predicate over property keys.
xs : list Z
list of items / code units scanned.
m : gmap nat Z
existing member map (Dictionary<string, JsonElement>).
k : nat
member key being inserted.
v : Z
member value being stored.
max_digits : list Z
reference decimal upper bound digits (Decimal.MaxValue).
Theorem wire_property_order_member_dedup_and_decimal_scan_eq
    (is_idx : Z -> bool) (xs max_digits : list Z) (m : gmap nat Z) (k : nat) (v : Z) :
  (Forall (fun x => is_idx x = false) xs ->
   List.filter is_idx xs ++ List.filter (fun x => negb (is_idx x)) xs = xs) /\
  bool_decide (size m < size (<[k := v]> m)) = bool_decide (m !! k = None) /\
  (scan_mantissa max_digits xs).1 = length (mantissa_digits xs) /\
  scan_fits_mantissa max_digits xs = ref_fits_mantissa max_digits (mantissa_digits xs).

Arguments

is_idx : Z -> bool
array-index predicate over property keys.
xs : list Z
list of items / code units scanned.
m : gmap nat Z
existing member map (Dictionary<string, JsonElement>).
k : nat
member key being inserted.
v : Z
member value being stored.
max_digits : list Z
reference decimal upper bound digits (Decimal.MaxValue).
Qed
Proof.
  assert (Hfilt_empty : forall ys, Forall (fun x => is_idx x = false) ys -> List.filter is_idx ys = []).
  { induction ys as [|x rest IH]; intros Hall; simpl; [reflexivity|].
    inversion Hall as [|? ? Hx Hrest]; subst. rewrite Hx. exact (IH Hrest). }
  assert (Hfilt_all : forall ys, Forall (fun x => is_idx x = false) ys -> List.filter (fun x => negb (is_idx x)) ys = ys).
  { induction ys as [|x rest IH]; intros Hall; simpl; [reflexivity|].
    inversion Hall as [|? ? Hx Hrest]; subst. rewrite Hx. simpl. rewrite (IH Hrest). reflexivity. }
  assert (Hfilter : Forall (fun x => is_idx x = false) xs ->
    List.filter is_idx xs ++ List.filter (fun x => negb (is_idx x)) xs = xs).
  { intros Hall. rewrite (Hfilt_empty xs Hall), (Hfilt_all xs Hall). reflexivity. }
  assert (Hsize : bool_decide (size m < size (<[k := v]> m)) = bool_decide (m !! k = None)).
  { destruct (m !! k) as [z|] eqn:Hk.
    - rewrite map_size_insert_Some; [|exists z; exact Hk].
      rewrite bool_decide_eq_false_2; [reflexivity | lia].
    - rewrite map_size_insert_None by exact Hk.
      rewrite bool_decide_eq_true_2; [reflexivity | lia]. }
  assert (Hdots : forall max_d ys st,
    foldl (step_mantissa_scan max_d) st ys =
    foldl (step_mantissa_scan max_d) st (List.filter (fun c => negb (Z.eqb c 46%Z)) ys)).
  { intros max_d ys. induction ys as [|y rest IH]; intros [sl cmp]; [reflexivity|].
    destruct (Z.eqb y 46%Z) eqn:Ed; cbn [foldl List.filter].
    - replace (step_mantissa_scan max_d (sl, cmp) y) with (sl, cmp)
        by (unfold step_mantissa_scan; rewrite Ed; reflexivity).
      rewrite Ed. simpl. apply IH.
    - rewrite Ed. simpl. apply IH. }
  assert (Hzeros : forall max_d ys cmp,
    Forall (fun c => c <> 46%Z) ys ->
    foldl (step_mantissa_scan max_d) (0, cmp) ys =
    foldl (step_mantissa_scan max_d) (0, cmp) (strip_leading_zeros ys)).
  { intros max_d ys cmp Hall. induction ys as [|y rest IH]; simpl; [reflexivity|].
    inversion Hall as [|? ? Hne46 Hrest]; subst.
    destruct (Z.eqb y 48%Z) eqn:Ez; simpl; [|rewrite ?Ez; reflexivity].
    rewrite (proj2 (Z.eqb_neq y 46%Z) Hne46), ?Ez. simpl.
    exact (IH Hrest). }
  assert (Hfilt_no46 : forall ys, Forall (fun c => c <> 46%Z) (List.filter (fun c => negb (Z.eqb c 46%Z)) ys)).
  { induction ys as [|y rest IH]; simpl; [constructor|].
    destruct (Z.eqb y 46%Z) eqn:Ed; simpl; [exact IH|].
    constructor; [exact (proj1 (Z.eqb_neq y 46%Z) Ed) | exact IH]. }
  assert (Hstrip_prop : forall ys,
    Forall (fun c => c <> 46%Z) ys ->
    Forall (fun c => c <> 46%Z) (strip_leading_zeros ys) /\
    match strip_leading_zeros ys with [] => True | d0 :: _ => d0 <> 48%Z end).
  { induction ys as [|y rest IH]; intros Hall; simpl; [split; [constructor | trivial]|].
    inversion Hall as [|? ? Hy Hrest]; subst.
    destruct (Z.eqb y 48%Z) eqn:Ez; [exact (IH Hrest)|].
    split; [constructor; assumption | exact (proj1 (Z.eqb_neq y 48%Z) Ez)]. }
  assert (Hlen_ds : forall max_d ds sl cmp,
    Forall (fun c => c <> 46%Z) ds ->
    (0 < sl \/ match ds with [] => True | d0 :: _ => d0 <> 48%Z end) ->
    (foldl (step_mantissa_scan max_d) (sl, cmp) ds).1 = sl + length ds).
  { intros max_d ds. induction ds as [|d rest IH]; intros sl cmp Hall Hguard; cbn [foldl length]; [simpl; lia|].
    inversion Hall as [|? ? Hd Hrest]; subst.
    assert (Hsl0 : (Nat.eqb sl 0 && Z.eqb d 48%Z) = false).
    { destruct Hguard as [Hpos | Hnz].
      - destruct sl; [lia | reflexivity].
      - rewrite (proj2 (Z.eqb_neq d 48%Z) Hnz). rewrite andb_false_r. reflexivity. }
    replace (step_mantissa_scan max_d (sl, cmp) d)
      with (S sl, if (sl <? length max_d) && Z.eqb cmp 0%Z then z_cmp d (nth sl max_d 0%Z) else cmp)
      by (unfold step_mantissa_scan; rewrite (proj2 (Z.eqb_neq d 46%Z) Hd), Hsl0; reflexivity).
    rewrite (IH (S sl) _ Hrest (or_introl (Nat.lt_0_succ sl))). lia. }
  assert (Hcmp_ds : forall ds pref max_rem cmp,
    Forall (fun c => c <> 46%Z) ds ->
    (0 < length pref \/ match ds with [] => True | d0 :: _ => d0 <> 48%Z end) ->
    length ds = length max_rem ->
    (foldl (step_mantissa_scan (pref ++ max_rem)) (length pref, cmp) ds).2 =
    (if Z.eqb cmp 0%Z then list_lex_cmp ds max_rem else cmp)).
  { induction ds as [|d rest IH]; intros pref max_rem cmp Hall Hguard Heqlen; cbn [foldl length list_lex_cmp] in *.
    - destruct max_rem; [|discriminate Heqlen].
      simpl. destruct (Z.eqb cmp 0%Z) eqn:E; [apply Z.eqb_eq in E; exact E | reflexivity].
    - destruct max_rem as [|mx max_rem']; [discriminate Heqlen|].
      injection Heqlen as Hrestlen.
      inversion Hall as [|? ? Hd Hrest]; subst.
      assert (Hsl0 : (Nat.eqb (length pref) 0 && Z.eqb d 48%Z) = false).
      { destruct Hguard as [Hpos | Hnz].
        - destruct (length pref); [lia | reflexivity].
        - rewrite (proj2 (Z.eqb_neq d 48%Z) Hnz). rewrite andb_false_r. reflexivity. }
      assert (Hlt : (length pref <? length (pref ++ mx :: max_rem')) = true).
      { apply Nat.ltb_lt. rewrite length_app. simpl. lia. }
      assert (Hnth : nth (length pref) (pref ++ mx :: max_rem') 0%Z = mx).
      { rewrite app_nth2 by lia. rewrite Nat.sub_diag. reflexivity. }
      replace (step_mantissa_scan (pref ++ mx :: max_rem') (length pref, cmp) d)
        with (S (length pref), if Z.eqb cmp 0%Z then z_cmp d mx else cmp)
        by (unfold step_mantissa_scan; rewrite (proj2 (Z.eqb_neq d 46%Z) Hd), Hsl0, Hlt, Hnth; simpl; reflexivity).
      assert (Happ : pref ++ mx :: max_rem' = (pref ++ [mx]) ++ max_rem')
        by (change (mx :: max_rem') with ([mx] ++ max_rem'); apply app_assoc).
      rewrite Happ.
      assert (Hnext_len : S (length pref) = length (pref ++ [mx]))
        by (rewrite length_app; simpl; lia).
      rewrite Hnext_len.
      assert (Hpref'_pos : 0 < length (pref ++ [mx])) by (rewrite length_app; simpl; lia).
      specialize (IH (pref ++ [mx]) max_rem'
        (if Z.eqb cmp 0%Z then z_cmp d mx else cmp)
        Hrest (or_introl Hpref'_pos) Hrestlen).
      rewrite IH.
      destruct (Z.eqb cmp 0%Z) eqn:Ecmp; simpl.
      + destruct (Z.eqb (z_cmp d mx) 0%Z); reflexivity.
      + rewrite ?Ecmp. reflexivity. }
  assert (Hm_props := Hstrip_prop _ (Hfilt_no46 xs)).
  destruct Hm_props as [Hm_no46 Hm_nz].
  split_and!.
  - exact Hfilter.
  - exact Hsize.
  - unfold scan_mantissa, mantissa_digits.
    rewrite Hdots, Hzeros by apply Hfilt_no46.
    exact (Hlen_ds max_digits _ 0 0%Z Hm_no46 (or_intror Hm_nz)).
  - unfold scan_fits_mantissa, ref_fits_mantissa, scan_mantissa.
    assert (Hlen_m : (foldl (step_mantissa_scan max_digits) (0, 0%Z) xs).1 = length (mantissa_digits xs)).
    { unfold mantissa_digits. rewrite Hdots, Hzeros by apply Hfilt_no46.
      exact (Hlen_ds max_digits _ 0 0%Z Hm_no46 (or_intror Hm_nz)). }
    destruct (foldl (step_mantissa_scan max_digits) (0, 0%Z) xs) as [sl cmp] eqn:Efold.
    simpl in Hlen_m. rewrite Hlen_m.
    destruct (length (mantissa_digits xs) <? length max_digits) eqn:Elt; simpl; [reflexivity|].
    destruct (length (mantissa_digits xs) =? length max_digits) eqn:Eeq; simpl; [|reflexivity].
    apply Nat.eqb_eq in Eeq.
    assert (Hcmp_m : cmp = list_lex_cmp (mantissa_digits xs) max_digits).
    { replace cmp with (foldl (step_mantissa_scan max_digits) (0, 0%Z) xs).2 by (rewrite Efold; reflexivity).
      unfold mantissa_digits in *.
      rewrite Hdots, Hzeros by apply Hfilt_no46.
      exact (Hcmp_ds _ [] max_digits 0%Z Hm_no46 (or_intror Hm_nz) Eeq). }
    rewrite Hcmp_m. reflexivity.
Qed.
References

Uses

37 more
  • None
  • S
  • bool
  • false
  • length
  • list
  • nat
  • negb
  • true
  • or_introl
  • or_intror
  • proj1
  • proj2
  • Forall
  • nth
  • Z
  • Nat.eqb
  • Nat.eqb_eq
  • Nat.lt_0_succ
  • Nat.ltb_lt
  • Nat.sub_diag
  • andb_false_r
  • app_assoc
  • app_nth2
  • filter
  • length_app
  • Z.eqb
  • Z.eqb_eq
  • Z.eqb_neq
  • size
  • bool_decide
  • bool_decide_eq_false_2
  • bool_decide_eq_true_2
  • map_size_insert_None
  • map_size_insert_Some
  • gmap
  • list.foldl
Definition wire_stop_lane (c : Z) :=
  Z.eqb c 34 || Z.eqb c 92 || Z.leb 55296 c.
References

Uses

  • Z
  • Z.eqb
  • Z.leb
Fixpoint wire_scalar_stop (xs : list Z) :=
  match xs with
  | [] => 0
  | c :: rest => if wire_stop_lane c then 0 else S (wire_scalar_stop rest)
  end.
References

Uses

Fixpoint trailing_clear (bits : list bool) :=
  match bits with
  | [] => 0
  | true :: _ => 0
  | false :: rest => S (trailing_clear rest)
  end.
References

Uses

  • S
  • bool
  • false
  • list
  • true
Definition wire_block_stop (block : list Z) next :=
  let mask := map wire_stop_lane block in
  if existsb id mask then trailing_clear mask else length block + next.
References

Uses

Lemma wire_block_stop_app block rest :
  wire_block_stop block (wire_scalar_stop rest) = wire_scalar_stop (block ++ rest).
Qed
Proof.
  unfold wire_block_stop. induction block as [|c cs IH]; simpl; [reflexivity|].
  destruct (wire_stop_lane c); simpl; [reflexivity|].
  destruct (existsb id (map wire_stop_lane cs)); simpl in *; by rewrite IH.
Qed.
References
✓ No axioms

Scanning successive vector masks and a scalar tail returns the first special UTF-16 lane. The block identity holds for any partition, including 32-, 16- and 8-lane blocks and skipped hardware tiers.

Theorem wire_vector_stop_eq (blocks : list (list Z)) tail :
  fold_right wire_block_stop (wire_scalar_stop tail) blocks =
  wire_scalar_stop (concat blocks ++ tail).
Qed
Proof.
  induction blocks as [|b bs IH]; simpl; [reflexivity|].
  rewrite IH, wire_block_stop_app, app_assoc. reflexivity.
Qed.
References

Uses

✓ No axioms

A unit selector preserves the result and tracked reads across model updates. The selector returns both its value and the sources it read for that model.

Theorem mvu_select_unit_history {A : Type} (select : Z -> A * list node_id)
    (states : list mvu_state) (previous : option A) :
  fold_right (fun st tail => (fun _ : option A => select (mvu_model st)) previous :: tail) [] states =
  map (fun st => (fun _ : unit => select (mvu_model st)) tt) states.
Qed
Proof. induction states; simpl; congruence. Qed.
References

Uses

2 more
  • Z
  • fold_right