elsmith 0.1.1

An Emacs Lisp language server with Lean-verified protocol and editing rules
Documentation
leanfran::lean! {
    pub mod proved;
    r#"
    structure Generation where
      openEpoch : Nat
      docVersion : Nat
      depGen : Nat
      configGen : Nat
      trustEpoch : Nat
      deriving DecidableEq, Repr

    def acceptDiagnostics (current : Option Generation) (completed : Generation) : Bool :=
      match current with
      | none => false
      | some live =>
        (live.openEpoch == completed.openEpoch) &&
        (live.docVersion == completed.docVersion) &&
        (live.depGen == completed.depGen) &&
        (live.configGen == completed.configGen) &&
        (live.trustEpoch == completed.trustEpoch)

    theorem accept_iff (current : Option Generation) (completed : Generation) :
        acceptDiagnostics current completed = true ↔ current = some completed := by
      cases current with
      | none => simp [acceptDiagnostics]
      | some live =>
        cases live
        cases completed
        simp [acceptDiagnostics, and_assoc]

    theorem rejects_closed (stale : Generation) : acceptDiagnostics none stale = false := rfl

    theorem rejects_out_of_order (live old : Generation) (changed : live ≠ old) :
        acceptDiagnostics (some live) old = false := by
      cases h : acceptDiagnostics (some live) old
      · rfl
      · exact False.elim (changed (Option.some.inj ((accept_iff _ _).mp h)))

    theorem rejects_after_edit (live old : Generation) (changed : live.docVersion ≠ old.docVersion) :
        acceptDiagnostics (some live) old = false :=
      rejects_out_of_order live old (fun h => changed (congrArg Generation.docVersion h))

    theorem rejects_after_reopen (live old : Generation) (changed : live.openEpoch ≠ old.openEpoch) :
        acceptDiagnostics (some live) old = false :=
      rejects_out_of_order live old (fun h => changed (congrArg Generation.openEpoch h))

    theorem rejects_after_dependency_change (live old : Generation) (changed : live.depGen ≠ old.depGen) :
        acceptDiagnostics (some live) old = false :=
      rejects_out_of_order live old (fun h => changed (congrArg Generation.depGen h))

    theorem rejects_after_configuration_change (live old : Generation)
        (changed : live.configGen ≠ old.configGen) :
        acceptDiagnostics (some live) old = false :=
      rejects_out_of_order live old (fun h => changed (congrArg Generation.configGen h))

    theorem rejects_after_revocation (live old : Generation) (changed : live.trustEpoch ≠ old.trustEpoch) :
        acceptDiagnostics (some live) old = false :=
      rejects_out_of_order live old (fun h => changed (congrArg Generation.trustEpoch h))
    "#
}

pub(crate) use proved::{Generation, accept_diagnostics};