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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions REUSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ named `budget` argument. The object index below supplies owners for those declar
| --- | --- |
| Find a tagged value from membership in its component history | `mem_restrict_iff` in `RandomSystems.System.Interconnection` |
| Locate a program query, including its final pending call | `DDC.exists_after_busy_of_mem_insideQueries` in `RandomSystems.Converter.ProgramTrace` |
| Preserve a caller's stopping bound under query recoding | `queryBounded_ddeOf_relabelQueries_iff` in `RandomSystems.System.QueryRelabel.Laws` |
| Decode register commands using inverses only on their operands and destinations | `mapCommand_mapCommand_eq_of_inverse_on` in `Commons.Definitions.AbstractModel.Domain` |
| Encode the register addresses used by a finite command set or bounded caller | `exists_fin_address_encoding`, `exists_fin_address_encoding_of_queryBounded` in `Commons.Definitions.AbstractModel.FiniteAddresses` |
| Move outside query and reply maps through attachment | `relabel_apply_outside_both` in `RandomSystems.DDC.DDCRelabel` |
Expand Down
16 changes: 16 additions & 0 deletions src/RandomSystems/System/QueryRelabel/Laws.lean
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public import RandomSystems.System.Distinguisher
`IsDDD.relabelQueries` preserves its interaction discipline.
`ddeOf_relabelQueries` maps its query strategy; `ddeOf_relabelQueries_map_decode`
recovers that strategy when decoding is inverse on the queries it can propose.
`queryBounded_ddeOf_relabelQueries_iff` preserves every stopping horizon.
These laws combine with `System.tr_relabel_input` to transport completed observations.
-/

Expand Down Expand Up @@ -67,6 +68,21 @@ lemma ddeOf_relabelQueries
trim_relabel D id _]
exact envOf_relabelQueries (trim D) code ys

/-- Query relabeling preserves each stopping bound, including bound zero. -/
lemma queryBounded_ddeOf_relabelQueries_iff
-- `valid` supplies the source caller's query environment; `code` changes only its queries.
{D : DDD I X Y} (valid : IsDDD D) (code : ∀ i, X i → X' i)
-- `n` is the same maximum number of queries before and after recoding.
(n : ℕ) :
QueryBounded n (ddeOf (IsDDD.relabelQueries valid code)) ↔
QueryBounded n (ddeOf valid) := by
have domains (ys : List (Σ i, Y i)) :
((ddeOf (IsDDD.relabelQueries valid code)).1 ys).Dom ↔
((ddeOf valid).1 ys).Dom := by
rw [ddeOf_relabelQueries, Part.map_Dom]
exact ⟨fun bounded ys h => bounded ys ((domains ys).mpr h),
fun bounded ys h => bounded ys ((domains ys).mp h)⟩

/-- A decoder need undo the code only on queries the original strategy can propose. -/
lemma ddeOf_relabelQueries_map_decode
-- `valid` supplies the source caller `D`'s query environment.
Expand Down
15 changes: 15 additions & 0 deletions src/Tests/QueryRelabel.lean
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ example :
(fun xs h => ⟨fun empty => h.1 (List.map_eq_nil_iff.mp empty),
by simpa only [List.length_map] using h.2⟩) caller caller_isDDD caller_closes

/-- The supported one-query caller keeps its exact bound after a noninjective coding. -/
example : QueryBounded 1 (ddeOf (IsDDD.relabelQueries caller_isDDD code)) :=
(queryBounded_ddeOf_relabelQueries_iff caller_isDDD code 1).mpr
(ddeOf_envProbe_queryBounded (DDE.ofQueries_queryBounded [request]) (fun _ => True))

/-- A caller that makes no resource query remains zero-bounded under the same coding. -/
example : QueryBounded 0 (ddeOf (IsDDD.relabelQueries
(envProbe_isDDD (A := fun _ => True)
(DDE.ofQueries_queryBounded (X := Σ _ : Unit, ℕ) (Y := Σ _ : Unit, Bool) []))
code)) :=
(queryBounded_ddeOf_relabelQueries_iff _ code 0).mpr
(ddeOf_envProbe_queryBounded (DDE.ofQueries_queryBounded []) (fun _ => True))

#print axioms queryBounded_ddeOf_relabelQueries_iff

#print axioms decoded_strategy
#print axioms final_decision
#print axioms caller_closes
Expand Down