Download data/lean/OAI/Computability/SpaceSimulation/Register/Search.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 2.65 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/SpaceSimulation/Register/Search.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/SpaceSimulation/Register/Search.lean
-
curl -L -o Search.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/SpaceSimulation/Register/Search.lean
2.65 kB
| import OAI.Computability.SpaceSimulation.Register.Arithmetic | |
| namespace OAI | |
| namespace Fifths | |
| namespace Scan | |
| def all (p : β β Bool) : β β Bool | |
| | 0 => true | |
| | n+1 => all p n && p n | |
| theorem all_iff (p : β β Bool) (n) : all p n = true β β j < n, p j = true := by | |
| induction n with | |
| | zero => simp [all] | |
| | succ n ih => | |
| rw [all, Bool.and_eq_true, ih] | |
| constructor | |
| Β· rintro β¨a,bβ© j l | |
| by_cases e : j < n | |
| Β· exact a _ e | |
| Β· rw [show j = n by omega] | |
| exact b | |
| Β· exact fun a => β¨fun j e => a _ (by omega), a n (by omega)β© | |
| def pick (p : β β Bool) : β β β | |
| | 0 => 0 | |
| | n+1 => if p n then n else pick p n | |
| theorem pick_le (p : β β Bool) (n) : pick p n β€ n := by | |
| induction n with | |
| | zero => rfl | |
| | succ n ih => simp only [pick]; split <;> omega | |
| theorem pick_spec (p : β β Bool) (n) (e : β j < n, p j = true) : | |
| pick p n < n β§ p (pick p n) = true := by | |
| induction n with | |
| | zero => simp at e | |
| | succ n ih => | |
| unfold pick | |
| split | |
| next h => exact β¨by omega,hβ© | |
| next h => | |
| suffices g : β j < n, p j = true from β¨by have := (ih g).1; omega,(ih g).2β© | |
| obtain β¨j,a,bβ© := e | |
| refine β¨j,?_,bβ© | |
| by_contra! v | |
| have l : j = n := by omega | |
| subst j | |
| contradiction | |
| end Scan | |
| namespace Comp | |
| variable {X I : Type} {x : I β List X} {S a b : I β β} | |
| theorem scanAll (p : I β β β Bool) (q : Comp x S a b) | |
| (h : β e : Before b β β, Comp (fun i => x i.1.1) (fun i => S i.1.1) e | |
| (fun i => a i.1.1) β Comp (fun i => x i.1.1) (fun i => S i.1.1) e (fun i => i.1.2) | |
| β Comp (fun i => x i.1.1) (fun i => S i.1.1) e | |
| (fun i => (p i.1.1 i.1.2).toNat)) : | |
| Comp x S a (fun i => (Scan.all (p i) (b i)).toNat) := by | |
| apply fold (fun i j => (Scan.all (p i) j).toNat) q | |
| (Comp.constant q.source 1) | |
| Β· exact (Fits.const _ 1).mono (fun _ => Bool.toNat_le _) | |
| Β· intro e i j r | |
| exact r.both (h e i j) | |
| theorem scanPick (p : I β β β Bool) (q : Comp x S a b) | |
| (h : β e : Before b β β, Comp (fun i => x i.1.1) (fun i => S i.1.1) e | |
| (fun i => a i.1.1) β Comp (fun i => x i.1.1) (fun i => S i.1.1) e (fun i => i.1.2) | |
| β Comp (fun i => x i.1.1) (fun i => S i.1.1) e | |
| (fun i => (p i.1.1 i.1.2).toNat)) : | |
| Comp x S a (fun i => Scan.pick (p i) (b i)) := by | |
| apply fold (fun i j => Scan.pick (p i) j) q | |
| (Comp.constant q.source 0) | |
| Β· let f : Through b β I := fun i => i.1.1 | |
| exact (q.target.pull f).mono (fun i => (Scan.pick_le _ _).trans i.2) | |
| Β· intro e i j r | |
| exact (h e i j).iteB j r | |
| end Comp | |
| end Fifths | |
| end OAI | |