Engine

7.7. Statements of Preconditions🔗

The exact statements behind the claims on the page Preconditions.

theorem precondition_sees_history_before_and_the_incoming_event (world : World) (before : List Event) (e : Event) : (Ctx.forPrecondition world before e).hist = before ∧ (Ctx.forPrecondition world before e).incoming = some e

proof: spec/Spec/Meaning.lean:418

theorem a_precondition_applies_exactly_when_its_on_picks_the_event (p : Pre) (world : World) (before : List Event) (e : Event) : p.applies world before e = true ↔ evalSelector (Ctx.forPrecondition world before e) [e] p.on ≠ []

proof: spec/Spec/Meaning.lean:424

theorem precondition_accepts_events_it_does_not_apply_to {p : Pre} {world : World} {before : List Event} {e : Event} (h : p.applies world before e = false) : p.accepts world before e = true

proof: spec/Spec/Meaning.lean:431

theorem a_precondition_accepts_an_event_it_applies_to_exactly_when_requires_holds {p : Pre} {world : World} {before : List Event} {e : Event} (h : p.applies world before e = true) : p.accepts world before e = true ↔ evalCondExpr (Ctx.forPrecondition world before e) p.requires = true

proof: spec/Spec/Meaning.lean:437

theorem a_count_in_requires_excludes_the_incoming_event (world : World) (before : List Event) (e : Event) (s : Selector) : evalValueExpr (Ctx.forPrecondition world before e) (.count s) = .num (evalSelector (Ctx.forPrecondition world before e) before s).length

proof: spec/Spec/Facts.lean:433

theorem a_checked_on_has_no_in {sc : Schema} {ent : String} {p : Pre} {u : Unit} (h : checkRule sc ent (.pre p) = .ok u) : p.on.isLocal = true

proof: spec/Spec/Lemmas.lean:82

theorem x_of_fields_is_x_where_each_field_is_the_incoming_field (ctx : Ctx) (hc : ctx.cur = none) (src : List Event) (t f : String) (fs : List String) : evalSelector ctx src (.byField t (f :: fs)) = evalSelector ctx src (.filter (.type t) (fieldsMatch f fs))

proof: spec/Spec/Laws.lean:223

theorem x_of_field_is_x_where_field_is_the_incoming_field (ctx : Ctx) (hc : ctx.cur = none) (src : List Event) (t f : String) : evalSelector ctx src (.byField t [f]) = evalSelector ctx src (.filter (.type t) (.cmp .eq (.field f) (.incoming f)))

proof: spec/Spec/Laws.lean:232

theorem roster_precondition_loads_without_errors : (loadFile rosterText).isOk

proof: spec/Spec/Readable.lean:307

theorem the_same_person_on_the_same_shift_twice_is_rejected : (parseCondExpr "never PersonAssigned(shift_id, person_id)").map (fun c => [(rosterRule c).accepts [personAssigned "S1" "P1"] (personAssigned "S1" "P1"), (rosterRule c).accepts [personAssigned "S1" "P1"] (personAssigned "S1" "P2"), (rosterRule c).accepts [personAssigned "S1" "P1"] (personAssigned "S2" "P1")]) = some [false, true, true]

proof: spec/Spec/Readable.lean:324

theorem in_on_the_incoming_field_and_the_field_pick_the_same_events (world : World) (before : List Event) (e : Event) (s : Selector) (hs : s.isLocal = true) (op : CmpOp) (f : String) (w : Value) : evalSelector (Ctx.forPrecondition world before e) [e] (.filter s (.cmp op (.incoming f) (.lit w))) = evalSelector (Ctx.forPrecondition world before e) [e] (.filter s (.cmp op (.field f) (.lit w)))

proof: spec/Spec/Lemmas.lean:71

theorem in_reachable_states_this_holds_for_every_deployed_precondition {st : State} (hr : Reachable st) {d : Deployed} (hd : d ∈ st.rules) (hn : d.toPos = none) {p : Pre} (hp : d.rule = .pre p) {s : Selector} (hs : p.on = .filter s (.cmp op (.incoming f) (.lit w))) (world : World) (before : List Event) (e : Event) : evalSelector (Ctx.forPrecondition world before e) [e] p.on = evalSelector (Ctx.forPrecondition world before e) [e] (.filter s (.cmp op (.field f) (.lit w)))

proof: spec/Spec/Lemmas.lean:90

def EveryHad (S : Selector) (C : CondExpr) (h : List Event) : Prop := ∀ i (hi : i < h.length), (evalSelector (Ctx.forPrecondition (worldOf (h.take i)) (h.take i) h[i]) [h[i]] S).isEmpty = false → evalCondExpr (Ctx.forPrecondition (worldOf (h.take i)) (h.take i) h[i]) C = true

proof: spec/Spec/Lemmas.lean:25

theorem a_precondition_held_exactly_when_every_picked_event_satisfied_it (S : Selector) (C : CondExpr) (ent k : String) (log : List Event) (hk : ∀ e ∈ log, e.entity = ent ∧ e.key = k) : PreconditionsHeld [{ entity := ent, rule := .pre { on := S, requires := C }, fromPos := 1 }] log ↔ EveryHad S C log

proof: spec/Spec/Lemmas.lean:39

def PreconditionsHeld (rules : List Deployed) (store : List Event) : Prop := ∀ i (hi : i < store.length), ∀ d ∈ rules, ∀ p, d.rule = .pre p → d.activeAt (i + 1) → d.entity = store[i].entity → p.accepts (worldOf (store.take i)) (keyHistory (store.take i) d.entity store[i].key) store[i] = true

proof: spec/Spec/Engine.lean:176

theorem each_precondition_accepted_every_event_in_its_lifetime {st : State} (hr : Reachable st) {d : Deployed} (hd : d ∈ st.rules) {p : Pre} (hp : d.rule = .pre p) {i : Nat} (hi : i < st.store.length) (hact : d.activeAt (i + 1) = true) (hent : d.entity = st.store[i].entity) : p.accepts (worldOf (st.store.take i)) (keyHistory (st.store.take i) d.entity st.store[i].key) st.store[i] = true

proof: spec/Spec/Meaning.lean:444

theorem minibar_precondition_loads_without_errors : (loadFile minibarText).isOk

proof: spec/Spec/Readable.lean:289

theorem charge_voided_precondition_loads_without_errors : (loadFile chargeVoidedText).isOk

proof: spec/Spec/Readable.lean:380

theorem closed_folio_precondition_loads_without_errors : (loadFile folioReopenedText).isOk

proof: spec/Spec/Readable.lean:396

theorem login_limit_precondition_loads_without_errors : (loadFile loginFailedText).isOk

proof: spec/Spec/Readable.lean:412

theorem recent_activity_precondition_loads_without_errors : (loadFile sessionStartedText).isOk

proof: spec/Spec/Readable.lean:428

theorem cancelled_reservation_precondition_loads_without_errors : (loadFile reservationCancelledText).isOk

proof: spec/Spec/Readable.lean:444