cfahlgren1's picture
download
raw
2.6 kB
10
lemma boolList_code_length (l : List Bool) : (encode l).length = 3*l.length := by
proof · 6 lines
  induction l with
  | nil => rfl
  | cons b l ih =>
    simp only [code_cons, pairBits_length, encode_bool, List.length_cons,
      List.length_nil, ih]
    omega
18
lemma state_code_length (s : State) :
    (encode s).length = 12*s.1.1.length + 6*s.1.2.length + 3*s.2.2.length + 6 := by
proof · 3 lines
  simp only [encode_prod, pairBits_length, boolList_code_length, encode_bool,
    List.length_singleton]
  omega
24
@[fun_prop] theorem xor_poly : Poly (fun z : Bool × Bool => xor z.1 z.2) := by
proof · 2 lines
  unfold xor
  fun_prop
28
@[fun_prop] theorem digit_poly : Poly (fun z : (Bool × Bool) × Bool => digit z.1.1 z.1.2 z.2) := by
proof · 2 lines
  unfold digit
  fun_prop
32
@[fun_prop] theorem carry_poly : Poly (fun z : (Bool × Bool) × Bool => carry z.1.1 z.1.2 z.2) := by
proof · 2 lines
  unfold carry
  fun_prop
36
@[fun_prop] theorem step_poly : Poly step := by
proof · 14 lines
  have hi : Poly (fun z : State × Bool =>
      ((z.1.1.1.headD false, z.1.1.2.headD false), z.1.2.1)) := by fun_prop
  have hc : Poly (fun z : State × Bool =>
      carry (z.1.1.1.headD false) (z.1.1.2.headD false) z.1.2.1) :=
    Poly.comp _ _ carry_poly hi
  have hd : Poly (fun z : State × Bool =>
      digit (z.1.1.1.headD false) (z.1.1.2.headD false) z.1.2.1) :=
    Poly.comp _ _ digit_poly hi
  have ho : Poly (fun z : State × Bool =>
      z.1.2.2 ++ [digit (z.1.1.1.headD false) (z.1.1.2.headD false) z.1.2.1]) :=
    Poly.comp (fun p : List Bool × Bool => p.1 ++ [p.2]) _ (by fun_prop)
      (Poly.pair _ _ (by fun_prop) hd)
  unfold step
  exact Poly.pair _ _ (by fun_prop) (Poly.pair _ _ hc ho)
52
lemma step_growth (z : State × Bool) :
    (encode (step z)).length ≤ (encode z.1).length + 1*(2*(encode z.2).length+1) := by
proof · 5 lines
  rw [state_code_length, state_code_length]
  simp only [step, encode_bool, List.length_singleton, List.length_append]
  have hx : z.1.1.1.tail.length ≤ z.1.1.1.length := by simp
  have hy : z.1.1.2.tail.length ≤ z.1.1.2.length := by simp
  omega
60
@[fun_prop] theorem run_poly : Poly (fun z : List Bool × State => run z.1 z.2) := by
proof · 1 line
  exact Poly.listFoldAdd step step_poly 1 step_growth
63
@[fun_prop] theorem initial_poly : Poly initial := by
proof · 2 lines
  unfold initial
  fun_prop
67
@[fun_prop] theorem finish_poly : Poly finish := by
proof · 2 lines
  unfold finish
  fun_prop
71
@[fun_prop] theorem add_poly : Poly add := by
proof · 2 lines
  unfold add
  fun_prop

Xet Storage Details

Size:
2.6 kB
·
Xet hash:
bccf09711f66a3419d9a8016adff20873d6933d4d7a5be35bc4e4758eacd432f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.