Documentation

Gossip.Error.Basic

Synchronous One-Error Gossip with Correction #

Basics #

Here we define: agents, values, distributions, calls, sequents.

We use n for the number of agents.

@[reducible, inline]
abbrev Error.Agent {n : ℕ} :
Equations
Instances For
    @[reducible, inline]
    abbrev Error.Value {n : ℕ} :
    Equations
    Instances For

      We allow writing just the agent a for the value ⟨a, true⟩.

      Equations

      We write ‾a for the value ⟨a, false⟩.

      Equations
      Instances For
        @[reducible, inline]
        abbrev Error.Dist {n : ℕ} :

        An initial secret distribution, each agent only has their own value.

        Equations
        Instances For
          def Error.Dist.switch {n : ℕ} :
          Agent → Dist → Dist

          In the given distribution, invert the value for this agent i

          Equations
          Instances For
            inductive Error.Call {n : ℕ} :
            Instances For
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    The pair of agents in the call, ignoring whether an error is made.

                    Equations
                    Instances For
                      @[reducible, inline]
                      abbrev Error.Sequence {n : ℕ} :

                      (Def 2) A sequence is a list of calls. For easy pattern matching this is in reverse order: the newest call is the first element.

                      Equations
                      Instances For
                        def Error.invert {n : ℕ} :

                        Flip the value of the secret of this agent in the given set.

                        Equations
                        Instances For
                          theorem Error.mem_invert_iff {n : ℕ} {c : Agent} {A : Set Value} {v : Value} :
                          v ∈ invert c A ↔ (if v.1 = c then (v.1, !v.2) else v) ∈ A

                          Membership in invert c A reduces to membership of the "flipped" value in A.

                          Syntax #

                          inductive Error.Form {n : ℕ} :

                          (Def 3) Logical language

                          Instances For
                            def Error.Form.length {n : ℕ} :
                            Form → ℕ
                            Equations
                            Instances For

                              Roles #

                              inductive Error.Role :
                              • Caller : Role
                              • Callee : Role
                              • Other : Role

                                Not participating in the call

                              Instances For
                                Equations
                                @[simp]
                                theorem Error.roleOfIn_eq_caller {n : ℕ} {a : Agent} {b : { b : Agent // b ≠ a }} :
                                @[simp]
                                theorem Error.roleOfIn_eq_callee {n : ℕ} {a : Agent} {b : { b : Agent // b ≠ a }} :
                                @[simp]
                                theorem Error.roleOfIn_fstE_eq_caller {n : ℕ} {a c : Agent} {b : { b : Agent // b ≠ a }} :
                                @[simp]
                                theorem Error.roleOfIn_fstE_eq_callee {n : ℕ} {a c : Agent} {b : { b : Agent // b ≠ a }} :
                                @[simp]
                                theorem Error.roleOfIn_sndE_eq_caller {n : ℕ} {a c : Agent} {b : { b : Agent // b ≠ a }} :
                                @[simp]
                                theorem Error.roleOfIn_sndE_eq_callee {n : ℕ} {a c : Agent} {b : { b : Agent // b ≠ a }} :
                                @[simp]
                                theorem Error.roleOfIn_eq_Caller_iff {n✝ : ℕ} {a x : Agent} {y : { b : Agent // b ≠ x }} :
                                @[simp]
                                theorem Error.roleOfIn_eq_Callee_iff {n✝ : ℕ} {a x : Agent} {y : { b : Agent // b ≠ x }} :
                                @[simp]
                                theorem Error.roleOfIn_eq_Other_iff {n✝ : ℕ} {a x : Agent} {y : { b : Agent // b ≠ x }} :
                                @[simp]
                                theorem Error.roleOfIn_fstE_eq_Caller_iff {n✝ : ℕ} {a x z : Agent} {y : { b : Agent // b ≠ x }} :
                                @[simp]
                                theorem Error.roleOfIn_fstE_eq_Callee_iff {n✝ : ℕ} {a x z : Agent} {y : { b : Agent // b ≠ x }} :
                                @[simp]
                                theorem Error.roleOfIn_fstE_eq_Other_iff {n✝ : ℕ} {a x z : Agent} {y : { b : Agent // b ≠ x }} :
                                @[simp]
                                theorem Error.roleOfIn_sndE_eq_Caller_iff {n✝ : ℕ} {a x : Agent} {y : { b : Agent // b ≠ x }} {z : Agent} :
                                @[simp]
                                theorem Error.roleOfIn_sndE_eq_Callee_iff {n✝ : ℕ} {a x : Agent} {y : { b : Agent // b ≠ x }} {z : Agent} :
                                @[simp]
                                theorem Error.roleOfIn_sndE_eq_Other_iff {n✝ : ℕ} {a x : Agent} {y : { b : Agent // b ≠ x }} {z : Agent} :
                                @[simp]
                                theorem Error.roleOfIn_pair_fst {n✝ : ℕ} {C : Call} :
                                @[simp]
                                theorem Error.roleOfIn_pair_snd {n✝ : ℕ} {C : Call} :

                                Sequences with at most one transmission error #

                                This sequence contains no transmission errors.

                                Equations
                                Instances For
                                  @[simp]
                                  def Error.maxOne {n : ℕ} :

                                  This sequence contains at most one transmission error.

                                  Equations
                                  Instances For
                                    @[simp]
                                    theorem Error.maxOne_nil {n : ℕ} :
                                    theorem Error.Sequence.maxOne_cons {n✝ : ℕ} {C : Call} {σ : List Call} :
                                    maxOne (C :: σ) → maxOne σ

                                    If o proves that C :: σ has at most one error then we use the short notation ⁻o to get a proof that σ has at most one error.

                                    Equations
                                    Instances For

                                      Sequence with at most one error.

                                      Equations
                                      Instances For

                                        Subsequence relation: σ⊑τ means that τ extends σ. Because sequences are lists with the newest call first we define this as List.IsSuffix σ τ.

                                        Equations
                                        Instances For
                                          Equations
                                          Instances For
                                            @[simp]
                                            @[simp]
                                            theorem Error.OSequence.ofLen_length {n k : ℕ} (σ : { σ : OSequence // σ.length = k }) :
                                            (↑σ).length = k
                                            @[simp]
                                            theorem Error.OSequence.maxOne {n : ℕ} {σ : OSequence} :

                                            Semantics #

                                            @[irreducible]
                                            def Error.resultSet {n : ℕ} (i : Agent) :

                                            (Def 4) Semantics of call. What values does this agent have after this sequence?

                                            Equations
                                            Instances For
                                              @[irreducible]
                                              def Error.contribSet {n : ℕ} (S : Dist) (σ : OSequence) :

                                              Right after sequence σ, what values will caller and callee contribute to the call?

                                              Equations
                                              Instances For
                                                @[irreducible]
                                                def Error.equiv {n k : ℕ} (a : Agent) :
                                                Dist × { σ : OSequence // σ.length = k } → Dist × { σ : OSequence // σ.length = k } → Prop

                                                (Def 5) Observation relation. This is synchronous.

                                                Equations
                                                Instances For
                                                  @[irreducible]
                                                  def Error.eval {n : ℕ} :
                                                  Dist → OSequence → Form → Prop

                                                  (Def 6) Semantics.

                                                  Equations
                                                  Instances For
                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      @[simp]
                                                      theorem Error.resultSet_nil {n : ℕ} {o : maxOne []} {S : Dist} {i : Agent} :
                                                      @[simp]
                                                      theorem Error.equiv_nil {n✝ : ℕ} {i : Agent} {S : Dist} {o1 : maxOne []} {a✝ : ℕ} {h1 : OSequence.length ⟨[], o1⟩ = a✝} {T : Dist} {o2 : maxOne []} {h2 : OSequence.length ⟨[], o2⟩ = a✝} :
                                                      equiv i (S, ⟨⟨[], o1⟩, h1⟩) (T, ⟨⟨[], o2⟩, h2⟩) ↔ S i = T i

                                                      Notation and Abbreviations #

                                                      We write v @ a to say that agent a has value v.

                                                      Equations
                                                      Instances For
                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            def Error.valid {n : ℕ} (φ : Form) :

                                                            Validity of formulas

                                                            Equations
                                                            Instances For
                                                              theorem Error.eval_biimpl {n✝ : ℕ} {S : Dist} {σ : OSequence} {φ1 φ2 : Form} :
                                                              S⌈σ⌉ ⊧ ( ¬'( ¬' ¬'φ1 ⋀ ¬'φ2) ⋀ ¬'( ¬' ¬'φ2 ⋀ ¬'φ1)) ↔ (S⌈σ⌉ ⊧ φ1 ↔ S⌈σ⌉ ⊧ φ2)
                                                              theorem Error.eval_impl {n✝ : ℕ} {S : Dist} {σ : OSequence} {φ1 φ2 : Form} :
                                                              S⌈σ⌉ ⊧ ( ¬'( ¬' ¬'φ1 ⋀ ¬'φ2)) ↔ S⌈σ⌉ ⊧ φ1 → S⌈σ⌉ ⊧ φ2
                                                              theorem Error.eval_con {n✝ : ℕ} {S : Dist} {σ : OSequence} {φ1 φ2 : Form} :
                                                              S⌈σ⌉ ⊧ (φ1 ⋀ φ2) ↔ S⌈σ⌉ ⊧ φ1 ∧ S⌈σ⌉ ⊧ φ2
                                                              theorem Error.eval_dis {n✝ : ℕ} {S : Dist} {σ : OSequence} {φ1 φ2 : Form} :
                                                              S⌈σ⌉ ⊧ ( ¬'( ¬'φ1 ⋀ ¬'φ2)) ↔ S⌈σ⌉ ⊧ φ1 ∨ S⌈σ⌉ ⊧ φ2

                                                              The observation relation is an equivalence #

                                                              def Error.equi {n : ℕ} (a : Agent) (Sσ Tτ : Dist × OSequence) :

                                                              An abbreviation to easily say that we have the same length and (can thus say) equiv.

                                                              Equations
                                                              Instances For
                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  theorem Error.equi_of_equiv {n✝ : ℕ} {a : Agent} {S : Dist} {σ : OSequence} {a✝ : ℕ} {h1 : σ.length = a✝} {T : Dist} {τ : OSequence} {h2 : τ.length = a✝} :
                                                                  equiv a (S, ⟨σ, h1⟩) (T, ⟨τ, h2⟩) → (S, σ) ~_ a(T, τ)
                                                                  theorem Error.equiv_of_equi {n✝ : ℕ} {a : Agent} {S : Dist} {σ : OSequence} {T : Dist} {τ : OSequence} {a✝ : ℕ} {h1 : σ.length = a✝} {h2 : τ.length = a✝} :
                                                                  (S, σ) ~_ a(T, τ) → equiv a (S, ⟨σ, h1⟩) (T, ⟨τ, h2⟩)
                                                                  theorem Error.sameRole_of_equiv {n✝ : ℕ} {a : Agent} {S : Dist} {C₁ : Call} {σ : List Call} {o1 : maxOne (C₁ :: σ)} {a✝ : ℕ} {h1 : OSequence.length ⟨C₁ :: σ, o1⟩ = a✝} {T : Dist} {C₂ : Call} {τ : List Call} {o2 : maxOne (C₂ :: τ)} {h2 : OSequence.length ⟨C₂ :: τ, o2⟩ = a✝} :
                                                                  equiv a (S, ⟨⟨C₁ :: σ, o1⟩, h1⟩) (T, ⟨⟨C₂ :: τ, o2⟩, h2⟩) → roleOfIn a C₁ = roleOfIn a C₂
                                                                  @[simp, irreducible]
                                                                  theorem Error.equiv_refl {n : ℕ} {a : Agent} {S : Dist} {k : ℕ} {σ : { σ : OSequence // σ.length = k }} :
                                                                  equiv a (S, σ) (S, σ)
                                                                  theorem Error.equiv_symm {n : ℕ} {i : Agent} {m : ℕ} {S : Dist} {σ : OSequence} {h1 : σ.length = m} {T : Dist} {τ : OSequence} {h2 : τ.length = m} :
                                                                  equiv i (S, ⟨σ, h1⟩) (T, ⟨τ, h2⟩) ↔ equiv i (T, ⟨τ, h2⟩) (S, ⟨σ, h1⟩)
                                                                  theorem Error.equiv_trans {n : ℕ} {a : Agent} {m : ℕ} {S : Dist} {σ : OSequence} {h1 : σ.length = m} {T : Dist} {τ : OSequence} {h2 : τ.length = m} {R : Dist} {ρ : OSequence} {h3 : ρ.length = m} :
                                                                  equiv a (S, ⟨σ, h1⟩) (T, ⟨τ, h2⟩) → equiv a (T, ⟨τ, h2⟩) (R, ⟨ρ, h3⟩) → equiv a (S, ⟨σ, h1⟩) (R, ⟨ρ, h3⟩)

                                                                  The observation relation equiv $∼_a$ is an equivalence relation.

                                                                  theorem Error.equiv_then_know_same {n : ℕ} {a : Agent} {m : ℕ} {S : Dist} {σ : OSequence} {h1 : σ.length = m} {T : Dist} {τ : OSequence} {h2 : τ.length = m} (equ : equiv a (S, ⟨σ, h1⟩) (T, ⟨τ, h2⟩)) (φ : Form) :
                                                                  S⌈σ⌉ ⊧ Form.K a φ ↔ T⌈τ⌉ ⊧ Form.K a φ
                                                                  theorem Error.not_in_call_equiv_of_equiv {n : ℕ} {κ : Call} {σ : Sequence} {o : maxOne (κ :: σ)} {τ : Sequence} {p : maxOne (κ :: τ)} {h1 : OSequence.length ⟨τ, ⋯⟩ = OSequence.length ⟨σ, ⋯⟩} {h2 : OSequence.length ⟨κ :: τ, p⟩ = OSequence.length ⟨κ :: σ, o⟩} {S T : Dist} (a : Agent) (not_in_call : roleOfIn a κ = Role.Other) (equ_before : equiv a (S, ⟨⟨σ, ⋯⟩, ⋯⟩) (T, ⟨⟨τ, ⋯⟩, h1⟩)) :
                                                                  equiv a (S, ⟨⟨κ :: σ, o⟩, ⋯⟩) (T, ⟨⟨κ :: τ, p⟩, h2⟩)