7.5. Statements of Reading the history
The exact statements behind the claims on the page Reading the history.
theorem the_field_of_an_aggregate_comes_after_a_complete_selector :
(parseValueExpr "sum(ChargePosted.gross_minor)").isSome ∧
(parseValueExpr "sum((ChargePosted where charge_type = 'Minibar').gross_minor)").isSome ∧
parseValueExpr "sum(any.gross_minor)" = noneproof: spec/Spec/Readable.lean:157
theorem count_is_the_number_of_picked_events (ctx : Ctx) (s : Selector) :
evalValueExpr ctx (.count s) = .num (evalSelector ctx ctx.hist s).lengthproof: spec/Spec/Laws.lean:286
theorem sum_adds_the_picked_values (ctx : Ctx) (s : Selector) (f : String) :
evalValueExpr ctx (.sum s f) = .num ((evalSelector ctx ctx.hist s).map fun e => numOrZero (e.get f)).sumproof: spec/Spec/Laws.lean:281
theorem a_number_counts_as_itself (q : Rat) : numOrZero (.num q) = qproof: spec/Spec/Meaning.lean:345
theorem anything_but_a_number_counts_as_zero {v : Value} (h : ∀ q, v ≠ .num q) :
numOrZero v = 0proof: spec/Spec/Meaning.lean:348
theorem sum_of_nothing_is_zero {ctx : Ctx} {s : Selector} (h : evalSelector ctx ctx.hist s = []) (f : String) :
evalValueExpr ctx (.sum s f) = .num 0proof: spec/Spec/Facts.lean:414
theorem count_splits_by_a_condition (ctx : Ctx) (s : Selector) (c : CondExpr) :
(evalSelector ctx ctx.hist s).length =
(evalSelector ctx ctx.hist (.filter s c)).length + (evalSelector ctx ctx.hist (.filter s (.not c))).lengthproof: spec/Spec/Laws.lean:297
theorem sum_splits_by_a_condition (ctx : Ctx) (s : Selector) (c : CondExpr) (f : String) (a b d : Rat)
(ha : evalValueExpr ctx (.sum s f) = .num a) (hb : evalValueExpr ctx (.sum (.filter s c) f) = .num b)
(hd : evalValueExpr ctx (.sum (.filter s (.not c)) f) = .num d) : a = b + dproof: spec/Spec/Laws.lean:311
theorem last_min_and_max_are_null_when_nothing_is_picked {ctx : Ctx} {s : Selector} (h : evalSelector ctx ctx.hist s = [])
(f : String) :
evalValueExpr ctx (.lastField s f) = .null ∧ evalValueExpr ctx (.min s f) = .null ∧
evalValueExpr ctx (.max s f) = .nullproof: spec/Spec/Facts.lean:407
theorem min_is_null_only_if_every_picked_value_is_null (ctx : Ctx) (s : Selector) (f : String) :
evalValueExpr ctx (.min s f) = .null ↔ ∀ e ∈ evalSelector ctx ctx.hist s, e.get f = .nullproof: spec/Spec/Facts.lean:390
theorem max_is_null_only_if_every_picked_value_is_null (ctx : Ctx) (s : Selector) (f : String) :
evalValueExpr ctx (.max s f) = .null ↔ ∀ e ∈ evalSelector ctx ctx.hist s, e.get f = .nullproof: spec/Spec/Facts.lean:399
theorem last_of_is_the_latest_picked_event {l : List Event} {e : Event} (h : l.getLast? = some e) :
e ∈ l ∧ ∃ before, l = before ++ [e]proof: spec/Spec/Laws.lean:257
theorem min_is_null_or_a_picked_value (ctx : Ctx) (s : Selector) (f : String) :
evalValueExpr ctx (.min s f) = .null ∨ ∃ e ∈ evalSelector ctx ctx.hist s, evalValueExpr ctx (.min s f) = e.get fproof: spec/Spec/Laws.lean:349
theorem max_is_null_or_a_picked_value (ctx : Ctx) (s : Selector) (f : String) :
evalValueExpr ctx (.max s f) = .null ∨ ∃ e ∈ evalSelector ctx ctx.hist s, evalValueExpr ctx (.max s f) = e.get fproof: spec/Spec/Laws.lean:342
theorem min_is_at_most_max (ctx : Ctx) (s : Selector) (f : String) {t : Ty} (ht : isOrdered t = true)
(hfs : ∀ e ∈ evalSelector ctx ctx.hist s, (e.get f).HasTy t)
(hn : evalValueExpr ctx (.min s f) ≠ .null) :
Value.cmp .le (evalValueExpr ctx (.min s f)) (evalValueExpr ctx (.max s f)) = trueproof: spec/Spec/Laws.lean:356
theorem max_at_most_v_is_never_greater_than_v (ctx : Ctx) (s : Selector) (f : String) (w : Value) {t : Ty}
(ht : isOrdered t = true) (hw : w.ty? = some t)
(hfs : ∀ e ∈ evalSelector ctx ctx.hist s, (e.get f).HasTy t)
(hne : ∃ e ∈ evalSelector ctx ctx.hist s, e.get f ≠ .null) :
evalCondExpr ctx (.cmp .le (.max s f) (.lit w)) =
evalCondExpr ctx (.never (.filter s (.cmp .gt (.field f) (.lit w))))proof: spec/Spec/Lemmas.lean:247
theorem min_at_least_v_is_never_less_than_v (ctx : Ctx) (s : Selector) (f : String) (w : Value) {t : Ty}
(ht : isOrdered t = true) (hw : w.ty? = some t)
(hfs : ∀ e ∈ evalSelector ctx ctx.hist s, (e.get f).HasTy t)
(hne : ∃ e ∈ evalSelector ctx ctx.hist s, e.get f ≠ .null) :
evalCondExpr ctx (.cmp .ge (.min s f) (.lit w)) =
evalCondExpr ctx (.never (.filter s (.cmp .lt (.field f) (.lit w))))proof: spec/Spec/Lemmas.lean:262
theorem max_at_most_v_is_false_on_nothing_but_never_greater_is_true (ctx : Ctx) (s : Selector) (f : String) (w : Value)
(h : evalSelector ctx ctx.hist s = []) :
evalCondExpr ctx (.cmp .le (.max s f) (.lit w)) = false ∧
evalCondExpr ctx (.never (.filter s (.cmp .gt (.field f) (.lit w)))) = trueproof: spec/Spec/Lemmas.lean:277
theorem there_is_no_avg : parseValueExpr "avg(Rated.stars)" = none