diff --git a/InductiveVerification.lean b/InductiveVerification.lean index 06a9158..1861a8f 100644 --- a/InductiveVerification.lean +++ b/InductiveVerification.lean @@ -1,17 +1,4 @@ -- This module serves as the root of the `InductiveVerification` library. -- Import modules here that should be built as part of the library. -import InductiveVerification.Basic - -inductive Agent - | Server : Agent - | Friend : Nat → Agent - | Spy : Agent - -inductive Msg - | Agent : Agent → Msg -- Agent names - | Number : Nat → Msg -- Ordinary integers, timestamps, ... - | Nonce : Nat → Msg -- Unguessable nonces - | Key : Key → Msg -- Crypto keys - | Hash : Msg → Msg -- Hashing - | MPair : Msg → Msg → Msg -- Compound messages - | Crypt : Key → Msg → Msg -- Encryption, public- or shared-key +import InductiveVerification.Message +import InductiveVerification.Event diff --git a/InductiveVerification/Basic.lean b/InductiveVerification/Basic.lean deleted file mode 100644 index 99415d9..0000000 --- a/InductiveVerification/Basic.lean +++ /dev/null @@ -1 +0,0 @@ -def hello := "world" diff --git a/InductiveVerification/Message.lean b/InductiveVerification/Message.lean index d6e1d9d..3588166 100644 --- a/InductiveVerification/Message.lean +++ b/InductiveVerification/Message.lean @@ -1,4 +1,17 @@ -import Mathlib +import Init.Data.Nat.Lemmas +import Init.Prelude +import Mathlib.Data.Nat.Basic +import Mathlib.Data.Nat.Dist +import Mathlib.Data.Set.Basic +import Mathlib.Data.Set.Defs +import Mathlib.Data.Set.Image +import Mathlib.Data.Set.Insert +import Mathlib.Data.Set.Lattice +import Mathlib.Order.Closure +import Mathlib.Order.Lattice +import Mathlib.Tactic.ApplyAt +import Mathlib.Tactic.SimpIntro +import Mathlib.Tactic.NthRewrite -- Keys are integers abbrev Key := Nat @@ -121,9 +134,11 @@ lemma keysFor_union (H H' : Set Msg) : keysFor (H ∪ H') = keysFor H ∪ keysFo -- Monotonicity @[simp] -lemma keysFor_mono {G H : Set Msg} (h : G ⊆ H) : keysFor G ⊆ keysFor H := by - simp - grind +lemma keysFor_mono: Monotone keysFor := by + simp_intro _ _ sub _ h + rcases h with ⟨K, ⟨⟨X, _⟩, _⟩⟩ ; exists K; apply And.intro + · exists X; aapply sub + · assumption -- Lemmas for `keysFor` with specific message types @[simp] @@ -321,7 +336,7 @@ lemma parts_idem {H : Set Msg} : parts (parts H) = parts H := lemma parts_subset_iff {G H : Set Msg} : (G ⊆ parts H) ↔ (parts G ⊆ parts H) := by apply partsClosureOperator.le_closure_iff -@[simp, grind] +@[simp] lemma parts_trans {G H : Set Msg} {X : Msg} : X ∈ parts G → G ⊆ parts H → X ∈ parts H := by intro a b; apply parts_mono at b; rw[parts_idem] at b; apply b; apply a; @@ -331,9 +346,12 @@ by intro a b; apply parts_mono at b; rw[parts_idem] at b; apply b; apply a; lemma parts_cut {G H : Set Msg} {X Y : Msg} : Y ∈ parts (insert X G) → X ∈ parts H → Y ∈ parts (G ∪ H) := by - intro a b; rw[parts_union]; rw[parts_insert] at a; cases a <;> grind - --- Rewrite rules for pulling out atomic messages + intro a b; rw[parts_union]; rw[parts_insert] at a; cases a <;> grind[parts_trans] + +@[simp] +lemma parts_cut_mono {G H : Set Msg} {X : Msg} : + X ∈ parts H → parts (insert X G) ⊆ parts (G ∪ H) := +by grind[parts_cut] @[simp] lemma parts_insert_Agent {H : Set Msg} {agt : Agent} : @@ -1320,7 +1338,7 @@ lemma pushKeysMPair {K : Key} {X Y : Msg} {H : Set Msg}: by simp [Set.insert_comm] lemma pushKeysCrypt {K K' : Key} {X : Msg} {H : Set Msg}: - insert (Key K) (insert (Crypt K' N) H) = insert (Crypt K' N) (insert (Key K) H) := + insert (Key K) (insert (Crypt K' X) H) = insert (Crypt K' X) (insert (Key K) H) := by simp [Set.insert_comm] lemma pushCryptsAgent {X : Msg} {K : Key} {C : Agent} {H : Set Msg} : diff --git a/Main.lean b/Main.lean index 9da78ea..c707829 100644 --- a/Main.lean +++ b/Main.lean @@ -1,4 +1,4 @@ import InductiveVerification def main : IO Unit := - IO.println s!"Hello, {hello}!" + IO.println "Hello, world!" diff --git a/lakefile.toml b/lakefile.toml index a836890..09d8c33 100644 --- a/lakefile.toml +++ b/lakefile.toml @@ -2,6 +2,10 @@ name = "inductive-verification" version = "0.1.0" defaultTargets = ["inductive-verification"] +[[require]] +name = "mathlib" +git = "https://github.com/leanprover-community/mathlib4.git" + [[lean_lib]] name = "InductiveVerification" diff --git a/lean-toolchain b/lean-toolchain index 7f254a9..fb18a7f 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:v4.23.0 +leanprover/lean4:v4.27.0-rc1 \ No newline at end of file