File size: 3,812 Bytes
e63eb7f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | import OAI.Combinatorics.EditApproximation.Probability.FiniteQueryWork
import OAI.Combinatorics.EditApproximation.Definitions
namespace OAI
/-! Restriction of adaptive read programs to a proved finite request domain.
The restriction visits the same reads whenever the original execution stays
in that domain. It does not enumerate the domain. -/
namespace EditApproximation.FiniteQuery
theorem mapKeys_id {ι : Type*} (program : FiniteQuery ι) : mapKeys id program = program := by
induction program with
| done result => rfl
| read key next ih =>
simp only [mapKeys, id_eq]
congr
funext answer
exact ih answer
theorem mapKeys_value {ι κ : Type*} (f : ι → κ) (oracle : κ → ℚ) (program : FiniteQuery ι) :
(mapKeys f program).value oracle = program.value (oracle ∘ f) := by
induction program with
| done result => rfl
| read key next ih => exact ih (oracle (f key))
theorem mapKeys_cost {ι κ : Type*} (f : ι → κ) (oracle : κ → ℚ) (weight : κ → ℕ)
(program : FiniteQuery ι) :
(mapKeys f program).cost oracle weight = program.cost (oracle ∘ f) (weight ∘ f) := by
induction program with
| done result => rfl
| read key next ih => exact congrArg (fun rest => weight (f key) + rest) (ih (oracle (f key)))
theorem mapKeys_keys {ι κ : Type*} (f : ι → κ) (oracle : κ → ℚ) (program : FiniteQuery ι) :
(mapKeys f program).keys oracle = (program.keys (oracle ∘ f)).map f := by
induction program with
| done result => rfl
| read key next ih => exact congrArg (List.cons (f key)) (ih (oracle (f key)))
theorem restrict_value {ι : Type*} (P : ι → Prop) [DecidablePred P]
(oracle : ι → ℚ) (program : FiniteQuery ι)
(hvalid : ∀ key ∈ program.keys oracle, P key) :
(restrict P program).value (fun key => oracle key.val) = program.value oracle := by
induction program with
| done result => rfl
| read key next ih =>
have hk : P key := hvalid key (by simp only [keys, List.mem_cons, true_or])
have hnext : ∀ other ∈ (next (oracle key)).keys oracle, P other := by
intro other hother
exact hvalid other (List.mem_cons_of_mem key hother)
simpa only [restrict, dite_eq_left hk, value] using ih (oracle key) hnext
theorem restrict_cost {ι : Type*} (P : ι → Prop) [DecidablePred P]
(oracle : ι → ℚ) (weight : ι → ℕ) (program : FiniteQuery ι)
(hvalid : ∀ key ∈ program.keys oracle, P key) :
(restrict P program).cost (fun key => oracle key.val) (fun key => weight key.val) =
program.cost oracle weight := by
induction program with
| done result => rfl
| read key next ih =>
have hk : P key := hvalid key (by simp only [keys, List.mem_cons, true_or])
have hnext : ∀ other ∈ (next (oracle key)).keys oracle, P other := by
intro other hother
exact hvalid other (List.mem_cons_of_mem key hother)
simpa only [restrict, dite_eq_left hk, cost] using
congrArg (fun rest => weight key + rest) (ih (oracle key) hnext)
theorem restrict_keys {ι : Type*} (P : ι → Prop) [DecidablePred P]
(oracle : ι → ℚ) (program : FiniteQuery ι)
(hvalid : ∀ key ∈ program.keys oracle, P key) :
((restrict P program).keys (fun key => oracle key.val)).map Subtype.val = program.keys oracle := by
induction program with
| done result => rfl
| read key next ih =>
have hk : P key := hvalid key (by simp only [keys, List.mem_cons, true_or])
have hnext : ∀ other ∈ (next (oracle key)).keys oracle, P other := by
intro other hother
exact hvalid other (List.mem_cons_of_mem key hother)
simpa only [restrict, dite_eq_left hk, keys, List.map_cons] using
congrArg (List.cons key) (ih (oracle key) hnext)
end EditApproximation.FiniteQuery
end OAI
|