Engine

7.8. Statements of Invariants🔗

The exact statements behind the claims on the page Invariants.

theorem an_invariant_holds_when_its_condition_holds_on_every_key (world : World) (store : List Event) (c : CondExpr) : Inv.holds world store (.always c) = true ↔ ∀ k ∈ keysOf store, evalCondExpr (Ctx.forInvariant world (history store k)) c = true

proof: spec/Spec/Meaning.lean:454

theorem a_grouped_invariant_holds_when_every_group_has_an_allowed_size (world : World) (store : List Event) (q : Quantity) (per : List Per) (values : List (String × ValueExpr)) (active : Option CondExpr) : Inv.holds world store (.grouped q per values active) = true ↔ ∀ g ∈ storeGroups world per values active store, q.allows (groupSize world per values active store g) = true

proof: spec/Spec/Meaning.lean:461

theorem dollar_field_now_windows_and_in_are_precondition_forms (s : Selector) (w : Window) (ent f : String) (k : ValueExpr) : (Selector.window s w).usesPreconditionForm = true ∧ (Selector.inEntity s ent k).usesPreconditionForm = true ∧ (ValueExpr.incoming f).usesPreconditionForm = true ∧ ValueExpr.now.usesPreconditionForm = true

proof: spec/Spec/Facts.lean:473

theorem a_deployed_invariant_uses_no_precondition_form {st st' : State} {sc : Schema} {fs : List RuleFile} (h : st.deploy sc fs = some st') {f : RuleFile} (hf : f ∈ fs) {i : Inv} (hi : Rule.inv i ∈ f.rules) : i.usesPreconditionForm = false

proof: spec/Spec/Facts.lean:588

theorem an_invariant_holds_at_every_position_while_it_is_active {st : State} (hr : Reachable st) {d : Deployed} (hd : d ∈ st.rules) {i : Inv} (hi : d.rule = .inv i) {p : Nat} (hp : p ≤ st.store.length) (ha : d.activeAt p = true) : invHolds (st.store.take p) d.entity i = true

proof: spec/Spec/Proofs.lean:179

theorem a_checked_invariant_reads_only_its_own_entity {sc : Schema} {rf : RuleFile} (ht : wellTyped sc rf) {i : Inv} (hi : Rule.inv i ∈ rf.rules) : i.isLocal

proof: spec/Spec/Invariants.lean:360

theorem an_invariant_depends_only_on_its_own_entity {i : Inv} (hl : i.isLocal) {s s' : List Event} {ent : String} (h : entityStore s ent = entityStore s' ent) : invHolds s ent i = invHolds s' ent i

proof: spec/Spec/Invariants.lean:374

theorem lower_bound_needs_a_state : invHolds [tm "MemberAdded"] "team" (.always teamNaive) = false ∧ firstWarn ["MemberAdded", "TeamActivated"] teamNaive = true ∧ invHolds [tm "MemberAdded"] "team" (.always (.or (.never "TeamActivated") teamNaive)) = true

proof: spec/Spec/Facts.lean:687

theorem the_first_event_warning_is_sound {types : List String} {c : CondExpr} (h : firstWarn types c = true) (w : World) (e : Event) (he : e.type ∈ types) : evalCondExpr (Ctx.forInvariant w [e]) c = false

proof: spec/Spec/Proofs.lean:488

theorem a_per_value_gives_one_choice (ctx : Ctx) (v : ValueExpr) : (Per.val v).choices ctx = [evalValueExpr ctx v]

proof: spec/Spec/Meaning.lean:477

theorem per_each_chooses_every_element_of_a_range (ctx : Ctx) (n : String) (v : ValueExpr) : (Per.each n v).choices ctx = (evalValueExpr ctx v).elems

proof: spec/Spec/Meaning.lean:480

theorem group_size_is_the_number_of_keys_in_the_group (world : World) (per : List Per) (values : List (String × ValueExpr)) (active : Option CondExpr) (store : List Event) (g : List Value) : groupSize world per values active store g = ((keysOf store).filter fun k => g ∈ groupsOf world per values active (history store k)).length

proof: spec/Spec/Meaning.lean:470

theorem a_group_has_no_null_value {world : World} {per : List Per} {values : List (String × ValueExpr)} {active : Option CondExpr} {h : List Event} {g : List Value} (hg : g ∈ groupsOf world per values active h) : ∀ v ∈ g, v ≠ .null

proof: spec/Spec/Facts.lean:597

theorem a_checked_group_has_at_least_one_key {world : World} {per : List Per} {values : List (String × ValueExpr)} {active : Option CondExpr} {store : List Event} {g : List Value} (hg : g ∈ storeGroups world per values active store) : 0 < groupSize world per values active store g

proof: spec/Spec/Facts.lean:613

theorem account_rules_load_without_errors : (loadFile accountText).isOk

proof: spec/Spec/Readable.lean:211

theorem balance_invariant_loads_without_errors : (loadFile balanceInvariantText).isOk

proof: spec/Spec/Readable.lean:245

theorem unique_email_invariant_loads_without_errors : (loadFile uniqueEmailText).isOk

proof: spec/Spec/Readable.lean:266