File size: 1,925 Bytes
4a56cd6 | 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 | import OAI.Computability.SpaceSimulation.Register.Arithmetic
namespace OAI
/-! Finite-case reasoning in the indexed complexity calculus. -/
namespace Fifths
namespace Comp
variable {X I Y : Type} {x : I β List X} {S a b : I β β}
theorem divideCases [Fintype Y] (code : Y β β) (inj : Function.Injective code)
{w : I β Y} (r : Comp x S a (fun i => code (w i)))
(h : β y, Comp (fun i : {i // w i = y} => x i) (fun i => S i) (fun i => a i)
(fun i => b i)) : Comp x S a b := by
classical
suffices g : β l : Finset Y,
Comp (fun i : {i // w i β l} => x i) (fun i => S i) (fun i => a i) (fun i => b i) from
(g Finset.univ).pull (fun i => β¨i,Finset.mem_univ (w i)β©)
intro l
induction l using Finset.induction_on with
| empty =>
let f := fun i : {i // w i β (β
: Finset Y)} => i.val
exact (Comp.constant (r.pull f).source 0).congr (fun i => by have a := i.property; simp at a)
| @insert y l m ih =>
let f := fun i : {i // w i β insert y l} => i.val
have p := r.pull f
let B (i : {i // w i β insert y l}) := decide (code (w (f i)) = code y)
refine (casesB (B := B) (p.eq (Comp.constant p.source (code y))) ?_ ?_)
Β· exact (h y).pull (fun i : {i // B i = true} => β¨f i.val,inj (of_decide_eq_true i.property)β©)
Β· exact ih.pull (fun i : {i // B i = false} => β¨f i.val,by
have g := Finset.mem_insert.mp i.val.property
rcases g with g|g
Β· have a := i.property
simp [B,f,g] at a
Β· exact gβ©)
theorem chooseCase [Fintype Y] (code : Y β β) (inj : Function.Injective code) {w : I β Y}
(p : I β Y β β) (r : Comp x S a (fun i => code (w i)))
(h : β y, Comp x S a (fun i => p i y)) :
Comp x S a (fun i => p i (w i)) := by
refine divideCases code inj r ?_
intro y
exact ((h y).pull _).congr (fun i => congrArg (p i) i.property.symm)
end Comp
end Fifths
end OAI
|