id
int64
1
500
thm_name
stringlengths
5
86
thm_stmt
stringlengths
30
2.63k
lean_root
stringclasses
23 values
rel_path
stringlengths
13
61
imports
listlengths
0
35
used_lib_defs
listlengths
1
144
used_repo_defs
listlengths
1
251
lib_lemmas
listlengths
1
172
repo_lemmas
listlengths
1
148
used_local_defs
listlengths
0
85
used_local_lemmas
listlengths
0
57
local_ctx
stringlengths
35
30.7k
target_theorem
stringlengths
33
1.57k
ground_truth_proof
stringlengths
6
26.5k
nesting_depth
int64
1
27
transitive_dep_count
int64
1
480
subset_aristotle
bool
2 classes
category
stringclasses
5 values
201
Intmax.isLUB_union_Merge_of_isLUB_isLUB_compat
lemma isLUB_union_Merge_of_isLUB_isLUB_compat {A B : Set (BalanceProof K₁ Kβ‚‚ C Pi V)} (h₁ : IsLUB A j₁) (hβ‚‚ : IsLUB B jβ‚‚) (h₃ : j₁ <β‰…> jβ‚‚) : IsLUB (A βˆͺ B) (j₁ <+> jβ‚‚)
FVIntmax
FVIntmax/Theorem1.lean
[ "import FVIntmax.Lemma5", "import FVIntmax.Wheels.AuthenticatedDictionary", "import FVIntmax.Request", "import FVIntmax.AttackGame", "import FVIntmax.Wheels", "import FVIntmax.Propositions", "import Mathlib", "import FVIntmax.Balance", "import FVIntmax.Lemma4", "import FVIntmax.Wheels.SignatureAggregation", "import FVIntmax.Lemma3" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "Finite", "module": "Mathlib.Data.Finite.Defs" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "IsLUB", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "IsLeast", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "LE", "module": "Init.Prelude" }, { "name": "LE.le", "module": "Init.Prelude" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "lowerBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "upperBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "Preorder.toLE", "module": "Mathlib.Order.Defs.PartialOrder" } ]
[ { "name": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b", "content": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b" }, { "name": "notation:51 π₁:52 \" <β‰…> \" Ο€β‚‚:52 => BalanceProof.compat π₁ Ο€β‚‚", "content": "notation:51 π₁:52 \" <β‰…> \" Ο€β‚‚:52 => BalanceProof.compat π₁ Ο€β‚‚" }, { "name": "notation:65 π₁:65 \" <+> \" Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚", "content": "notation:65 π₁:65 \" <+> \" Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚" }, { "name": "BalanceProof", "content": "abbrev BalanceProof (K₁ Kβ‚‚ : Type) [Finite K₁] [Finite Kβ‚‚]\n (C Pi V : Type) [PreWithZero V] : Type :=\n Dict (C Γ— Kβ‚‚) ((Pi Γ— ExtraDataT) Γ— TransactionBatch K₁ Kβ‚‚ V) " }, { "name": "TransactionBatch", "content": "abbrev TransactionBatch (K₁ : Type) [Finite K₁]\n (Kβ‚‚ : Type) [Finite Kβ‚‚]\n (V : Type) [PreWithZero V] :=\n Key K₁ Kβ‚‚ β†’ Vβ‚Š" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "Merge", "content": "def Merge (D₁ Dβ‚‚ : Dict Ξ± Ο‰) : Dict Ξ± Ο‰ := D\n where D := Ξ» x ↦ First (D₁ x) (Dβ‚‚ x)" }, { "name": "First", "content": "def First (x₁ xβ‚‚ : Option Ξ±) : Option Ξ± :=\n match x₁, xβ‚‚ with\n | .some x, .none => .some x\n | .some x, .some _ => .some x\n | .none, .some y => .some y\n | .none, .none => .none" }, { "name": "Setoid'", "content": "class Setoid' (X : Type) extends Preorder X where\n isEquiv : IsEquivRel (X := X)" }, { "name": "IsEquivRel", "content": "def IsEquivRel {X : Type} [Preorder X] := βˆ€ a b : X, a ≀ b ↔ a β‰… b" }, { "name": "iso", "content": "def iso {X : Type} [Preorder X] (a b : X) := a ≀ b ∧ b ≀ a" }, { "name": "trivialPreorder", "content": "def trivialPreorder {Ξ± : Type} : Preorder Ξ± :=\n {\n lt := Ξ» _ _ ↦ False\n le := Ξ» _ _ ↦ True\n le_refl := by admit /- proof elided -/" }, { "name": "le", "content": "def le (v₁ vβ‚‚ : Vector Ξ± n) :=\n βˆ€ x ∈ (v₁.1.zip vβ‚‚.1), x.1 ≀ x.2" }, { "name": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b", "content": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "Set.mem_insert_iff", "module": "Mathlib.Data.Set.Insert" }, { "name": "Set.mem_setOf_eq", "module": "Mathlib.Data.Set.Operations" }, { "name": "Set.mem_singleton_iff", "module": "Mathlib.Data.Set.Insert" }, { "name": "Set.mem_union", "module": "Mathlib.Data.Set.Basic" }, { "name": "and_imp", "module": "Init.SimpLemmas" }, { "name": "forall_eq", "module": "Init.PropLemmas" }, { "name": "forall_eq_or_imp", "module": "Init.PropLemmas" } ]
[ { "name": "proposition6", "content": "lemma proposition6 [Setoid' Y] {D₁ Dβ‚‚ : Dict X Y} :\n (βˆƒ join, IsLUB {D₁, Dβ‚‚} join) ↔ βˆ€ x, D₁ x β‰  .none ∧ Dβ‚‚ x β‰  .none β†’ D₁ x β‰… Dβ‚‚ x" }, { "name": "proposition4", "content": "lemma proposition4 [Setoid' X] {x y : Option X} :\n (βˆƒ join : Option X, IsLUB {x, y, .none} join) ↔ (x β‰  .none ∧ y β‰  .none β†’ x β‰… y)" }, { "name": "proposition2", "content": "lemma proposition2 [Setoid' X] {x y : X} :\n (βˆƒ join : X, IsLUB {x, y} join) ↔ x β‰… y" }, { "name": "iso_rfl", "content": "@[simp, refl]\nlemma iso_rfl : a β‰… a" }, { "name": "iso_trans", "content": "@[trans]\nlemma iso_trans : (a β‰… b) β†’ (b β‰… c) β†’ a β‰… c" }, { "name": "proposition2'", "content": "lemma proposition2' [Setoid' X] {join x y : X} (h : IsLUB {x, y} join) :\n (x β‰… join) ∧ y β‰… join" }, { "name": "proposition3'", "content": "lemma proposition3' : \n (βˆƒ join : X, IsLUB {x, y} join) ↔ (βˆƒ join : Option X, IsLUB {.some x, .some y, .none} join)" }, { "name": "proposition5", "content": "lemma proposition5 [Preorder Y] {f g : X β†’ Y} {join : X β†’ Y} :\n IsLUB {f, g} join ↔ βˆ€ x : X, IsLUB {f x, g x} (join x)" }, { "name": "proposition6_aux", "content": "lemma proposition6_aux [Setoid' Y] {D₁ Dβ‚‚ : Dict X Y}\n (h : βˆ€ k, D₁ k β‰  .none ∧ Dβ‚‚ k β‰  .none β†’ D₁ k β‰… Dβ‚‚ k) : IsLUB {D₁, Dβ‚‚} (Dict.Merge D₁ Dβ‚‚)" }, { "name": "proposition6'", "content": "lemma proposition6' [Setoid' Y] {D₁ Dβ‚‚ join : Dict X Y} (h : IsLUB {D₁, Dβ‚‚} join) :\n join β‰… Dict.Merge D₁ Dβ‚‚" }, { "name": "iso_symm", "content": "@[symm]\nlemma iso_symm : (a β‰… b) ↔ b β‰… a" }, { "name": "proposition4'", "content": "lemma proposition4' [Setoid' X] {join x y : Option X} (h : IsLUB {x, y, .none} join) :\n join β‰… Dict.First x y" }, { "name": "proposition5'", "content": "lemma proposition5' [Preorder Y] {f g h join' : X β†’ Y}\n (hβ‚€ : IsLUB {f, g} join')\n (h₁ : βˆ€ x, h x β‰… join' x) :\n join' β‰… h" }, { "name": "discretePreorder_eq_equality_Pi_Prod_ExtraDataT", "content": "@[simp]\nlemma discretePreorder_eq_equality_Pi_Prod_ExtraDataT {a b : (Pi Γ— ExtraDataT)} : a ≀ b" }, { "name": "BalanceProof.snd_discrete", "content": "@[simp]\nlemma BalanceProof.snd_discrete {x y : TransactionBatch K₁ Kβ‚‚ V} :\n @LE.le (TransactionBatch K₁ Kβ‚‚ V) Preorder.toLE x y ↔ x = y" } ]
[]
[ { "name": "Intmax.existsLUB_iff_compat", "content": "lemma existsLUB_iff_compat :\n (βˆƒ join, IsLUB {π₁, Ο€β‚‚} join) ↔ π₁ <β‰…> Ο€β‚‚" }, { "name": "Intmax.merge_le", "content": "lemma merge_le (h₁ : π₁ ≀ π₃) (hβ‚‚ : Ο€β‚‚ ≀ π₃) : π₁ <+> Ο€β‚‚ ≀ π₃" } ]
import FVIntmax.AttackGame import FVIntmax.Lemma3 import FVIntmax.Lemma4 import FVIntmax.Lemma5 import FVIntmax.Propositions import FVIntmax.Request import FVIntmax.Wheels import FVIntmax.Wheels.AuthenticatedDictionary import FVIntmax.Wheels.SignatureAggregation import Mathlib namespace Intmax open Classical noncomputable section Intmax noncomputable section theorem1 section AttackGame variable {Sigma Pi M : Type} {C : Type} [Nonempty C] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] {K₁ : Type} [Nonempty K₁] [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {Kβ‚š : Type} [Nonempty Kβ‚š] {Kβ‚› : Type} [Nonempty Kβ‚›] section MergeLemmas variable {acc Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V} {Ο€s Ο€s : List (BalanceProof K₁ Kβ‚‚ C Pi V)} end MergeLemmas notation:51 π₁:52 " <β‰…> " Ο€β‚‚:52 => BalanceProof.compat π₁ Ο€β‚‚ notation:65 π₁:65 " <+> " Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚ section Compat variable {π₁ Ο€β‚‚ π₃ : BalanceProof K₁ Kβ‚‚ C Pi V} end Compat
lemma isLUB_union_Merge_of_isLUB_isLUB_compat {A B : Set (BalanceProof K₁ Kβ‚‚ C Pi V)} (h₁ : IsLUB A j₁) (hβ‚‚ : IsLUB B jβ‚‚) (h₃ : j₁ <β‰…> jβ‚‚) : IsLUB (A βˆͺ B) (j₁ <+> jβ‚‚) :=
:= by have h₃'' := h₃ obtain ⟨j, hβ‚ƒβŸ© := existsLUB_iff_compat.2 h₃ split_ands Β· simp only [IsLUB, IsLeast, upperBounds, Set.mem_insert_iff, Set.mem_singleton_iff, forall_eq_or_imp, forall_eq, Set.mem_setOf_eq, lowerBounds, and_imp, Set.mem_union] at h₁ hβ‚‚ h₃ ⊒ rcases h₁ with ⟨h₁, h₁'⟩ rcases hβ‚‚ with ⟨hβ‚‚, hβ‚‚'⟩ rintro D₁ (hD₁ | hDβ‚‚) Β· simp [-Prod.forall, (·≀·)] intros x unfold Dict.Merge Dict.Merge.D Dict.First specialize h₁ hD₁ simp [-Prod.forall, (·≀·)] at h₁ specialize h₁ x set d₁ := D₁ x with eqX set dβ‚‚ := j₁ x with eqY set d₃ := jβ‚‚ x with eqZ rcases d₁ with _ | d₁ <;> rcases dβ‚‚ with _ | dβ‚‚ <;> rcases d₃ with _ | d₃ <;> simp Β· simp at h₁ Β· simp at h₁ Β· simp at h₁ exact h₁ Β· simp at h₁ exact h₁ Β· simp only [LE.le, discretePreorder_eq_equality_Pi_Prod_ExtraDataT, BalanceProof.snd_discrete,] intros x unfold Dict.Merge Dict.Merge.D Dict.First have eqβ‚‚ : D₁ ≀ jβ‚‚ := hβ‚‚ hDβ‚‚ simp [-Prod.forall, (·≀·)] at eqβ‚‚ specialize eqβ‚‚ x set d₁ := D₁ x with eqX set dβ‚‚ := j₁ x with eqY set d₃ := jβ‚‚ x with eqZ rcases d₁ with _ | d₁ <;> rcases dβ‚‚ with _ | dβ‚‚ <;> rcases d₃ with _ | d₃ <;> simp Β· simp at eqβ‚‚ Β· simp at eqβ‚‚ exact eqβ‚‚ Β· simp at eqβ‚‚ Β· simp at eqβ‚‚ specialize h₃'' x rw [←eqY, ←eqZ] at h₃'' simp at h₃'' exact iso_trans eqβ‚‚ h₃''.symm Β· exact Ξ» _ hΟ€ ↦ merge_le (h₁.right Ξ» _ hd ↦ hΟ€ (by tauto)) (hβ‚‚.right Ξ» _ hd ↦ hΟ€ (by tauto))
7
52
false
Applied verif.
202
Intmax.Vec.le_trans
lemma le_trans (h₁ : v₁ ≀ vβ‚‚) (hβ‚‚ : vβ‚‚ ≀ v₃) : v₁ ≀ v₃
FVIntmax
FVIntmax/Wheels.lean
[ "import Mathlib.Logic.Embedding.Basic", "import FVIntmax.Wheels.Wheels", "import Mathlib.Tactic", "import Mathlib.Algebra.Order.Ring.Unbundled.Nonneg", "import Mathlib.Data.Finmap", "import Mathlib.Data.Set.Image", "import Mathlib.Data.Finite.Defs", "import Mathlib.Data.List.Intervals" ]
[ { "name": "Vector", "module": "Init.Data.Vector.Basic" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Intmax.CryptoAssumptions.Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "Intmax.Vec.le", "content": "def le (v₁ vβ‚‚ : Vector Ξ± n) :=\n βˆ€ x ∈ (v₁.1.zip vβ‚‚.1), x.1 ≀ x.2" } ]
[]
import Mathlib.Algebra.Order.Ring.Unbundled.Nonneg import Mathlib.Data.Finite.Defs import Mathlib.Data.Finmap import Mathlib.Data.List.Intervals import Mathlib.Data.Set.Image import Mathlib.Logic.Embedding.Basic import Mathlib.Tactic import FVIntmax.Wheels.Wheels namespace Intmax namespace CryptoAssumptions section Hashing class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where h : ComputationallyInfeasible (Β¬ Function.Injective f) end Hashing end CryptoAssumptions section UniquelyIndexed prefix:max "!" => UniqueTokenT namespace UniquelyIndexed end UniquelyIndexed end UniquelyIndexed section NonNeg postfix:max "β‚Š" => NonNeg section Nonneg variable {Ξ± : Type} [PreWithZero Ξ±] {v : Ξ±β‚Š} end Nonneg end NonNeg section Order section VectorPreorder open Mathlib variable {Ξ± : Type} [Preorder Ξ±] {n : β„•} {v₁ vβ‚‚ v₃ : Vector Ξ± n} namespace Vec def le (v₁ vβ‚‚ : Vector Ξ± n) := βˆ€ x ∈ (v₁.1.zip vβ‚‚.1), x.1 ≀ x.2
lemma le_trans (h₁ : v₁ ≀ vβ‚‚) (hβ‚‚ : vβ‚‚ ≀ v₃) : v₁ ≀ v₃ :=
:= by dsimp [(·≀·), le] at * rcases v₁ with ⟨l₁, hlβ‚βŸ© rcases vβ‚‚ with ⟨lβ‚‚, hlβ‚‚βŸ© rcases v₃ with ⟨l₃, hlβ‚ƒβŸ© simp at * induction' lβ‚‚ with hdβ‚‚ tlβ‚‚ ih generalizing l₁ l₃ n Β· rcases l₃; exact h₁; simp_all; omega Β· rcases l₃ with _ | ⟨hd₃, tlβ‚ƒβŸ© <;> [simp; skip] rcases l₁ with _ | ⟨hd₁, tlβ‚βŸ© <;> simp at * intros a b h rcases h with ⟨h₃, hβ‚„βŸ© | h Β· transitivity hdβ‚‚ <;> tauto Β· specialize @ih tl₁.length tl₁ rfl (by aesop) tl₃ (by aesop) aesop
2
3
false
Applied verif.
203
Intmax.monotone_TransactionsInBlocksFixed
lemma monotone_TransactionsInBlocksFixed : Monotone Ξ» (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) ↦ TransactionsInBlocksFixed Ο€ Bstar
FVIntmax
FVIntmax/Lemma4.lean
[ "import FVIntmax.Wheels.Dictionary", "import FVIntmax.Wheels", "import FVIntmax.Balance" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "Finite", "module": "Mathlib.Data.Finite.Defs" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" }, { "name": "Classical.arbitrary", "module": "Mathlib.Logic.Nonempty" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "Monotone", "module": "Mathlib.Order.Monotone.Defs" }, { "name": "Finset.sort", "module": "Mathlib.Data.Finset.Sort" }, { "name": "LE", "module": "Init.Prelude" }, { "name": "List.length", "module": "Init.Prelude" }, { "name": "List.map", "module": "Init.Prelude" }, { "name": "Subtype", "module": "Init.Prelude" } ]
[ { "name": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$", "content": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$b, by admit /- proof elided -/\n⟩)" }, { "name": "BalanceProof", "content": "abbrev BalanceProof (K₁ Kβ‚‚ : Type) [Finite K₁] [Finite Kβ‚‚]\n (C Pi V : Type) [PreWithZero V] : Type :=\n Dict (C Γ— Kβ‚‚) ((Pi Γ— ExtraDataT) Γ— TransactionBatch K₁ Kβ‚‚ V) " }, { "name": "TransactionBatch", "content": "abbrev TransactionBatch (K₁ : Type) [Finite K₁]\n (Kβ‚‚ : Type) [Finite Kβ‚‚]\n (V : Type) [PreWithZero V] :=\n Key K₁ Kβ‚‚ β†’ Vβ‚Š" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "TransactionsInBlocks", "content": "def TransactionsInBlocks\n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (bs : List (Block K₁ Kβ‚‚ C Sigma V)) : List (Ξ€ K₁ Kβ‚‚ V) :=\n (bs.map (TransactionsInBlock Ο€)).flatten" }, { "name": "TransactionsInBlock", "content": "def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := \n match h : b with\n | .deposit .. => TransactionsInBlock_deposit β†ͺb\n | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb\n | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb" }, { "name": "TransactionsInBlock_withdrawal", "content": "def TransactionsInBlock_withdrawal \n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .withdrawal withdrawals =>\n \n let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·)\n k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/\n ⟩\n | .deposit r v | .transfer .. => by admit /- proof elided -/" }, { "name": "Block", "content": "inductive Block (K₁ Kβ‚‚ : Type) (C Sigma : Type) (V : Type) [PreWithZero V] where\n \n | deposit (recipient : Kβ‚‚) (amount : Vβ‚Š)\n \n | transfer (aggregator : K₁) (extradata : ExtraDataT) (commitment : C) (senders : List Kβ‚‚) (sigma : Sigma)\n \n | withdrawal (withdrawals : K₁ β†’ Vβ‚Š)" }, { "name": "isWithdrawalBlock", "content": "abbrev isWithdrawalBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.withdrawal _)" }, { "name": "attach", "content": "noncomputable def attach (Ξ± : Type) [Finite Ξ±] : UniquelyIndexed Ξ± :=\n have := Finite.exists_equiv_fin Ξ±\n this.choose_spec.some.toEmbedding" }, { "name": "UniquelyIndexed", "content": "abbrev UniquelyIndexed (Ξ± : Type) [Finite Ξ±] : Type := Ξ± β†ͺ !Ξ±" }, { "name": "UniqueTokenT", "content": "abbrev UniqueTokenT (Ξ± : Type) [Finite Ξ±] : Type := Fin (Finite.exists_equiv_fin Ξ± |>.choose)" }, { "name": "Ξ€", "content": "abbrev Ξ€ (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { Ο„ : Ξ€' K₁ Kβ‚‚ V // Ο„.isValid }" }, { "name": "Ξ€'", "content": "abbrev Ξ€' (K₁ Kβ‚‚ V : Type) [PreWithZero V] := Kbar K₁ Kβ‚‚ Γ— Kbar K₁ Kβ‚‚ Γ— Option Vβ‚Š" }, { "name": "Kbar", "content": "inductive Kbar (K₁ Kβ‚‚ : Type) where\n | key (k : Key K₁ Kβ‚‚)\n | Source\nderiving DecidableEq" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "TransactionsInBlock_transfer", "content": "def TransactionsInBlock_transfer \n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .transfer _ _ commitment S _ =>\n \n let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) }\n let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe \n \n let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š :=\n if s βˆ‰ S\n then .some 0\n else \n if h : (commitment, s) ∈ Ο€.keys\n then let (_, t) := Ο€[(commitment, s)]\n t r\n else .none\n sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/\n ⟩\n | .deposit .. | .withdrawal .. => by admit /- proof elided -/" }, { "name": "lexLe", "content": "def lexLe (a b : Kβ‚‚ Γ— Key K₁ Kβ‚‚) : Prop :=\n a.1 < b.1 ∨ (a.1 = b.1 ∧ a.2 ≀ b.2)" }, { "name": "isTransferBlock", "content": "abbrev isTransferBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.transfer _ _ _ _ _)" }, { "name": "keys", "content": "def keys (m : Dict Ξ± Ο‰) : Set Ξ± := { x | Dict.is_mem m x }" }, { "name": "Dict.is_mem", "content": "def Dict.is_mem (m : Dict Ξ± Ο‰) (x : Ξ±) : Prop := (m x).isSome" }, { "name": "keys", "content": "abbrev keys (ct : CommitT C K Pi) := ct.dict.keys" }, { "name": "CommitT", "content": "structure CommitT (C K Pi : Type) where\n commitment : C\n dict : Dict K Pi" }, { "name": "keysUneq", "content": "abbrev keysUneq (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) : Prop :=\n match k with\n | .inl _ => True\n | .inr kβ‚‚' => kβ‚‚ β‰  kβ‚‚'" }, { "name": "TransactionsInBlock_deposit", "content": "def TransactionsInBlock_deposit\n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/\n ⟩]\n | .withdrawal .. | .transfer .. => by admit /- proof elided -/" }, { "name": "isDepositBlock", "content": "abbrev isDepositBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.deposit _ _) " }, { "name": "le", "content": "def le (v₁ vβ‚‚ : Vector Ξ± n) :=\n βˆ€ x ∈ (v₁.1.zip vβ‚‚.1), x.1 ≀ x.2" }, { "name": "v'", "content": "def v' (v : Vβ‚Š) (b : S K₁ Kβ‚‚ V) (s : Kbar K₁ Kβ‚‚) : Vβ‚Š :=\n match h : s with\n | .Source => v\n | .key _ => ⟨v βŠ“ b s, by admit /- proof elided -/\n ⟩" }, { "name": "S", "content": "abbrev S (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { s : S' K₁ Kβ‚‚ V // s.isValid }" }, { "name": "S'", "content": "abbrev S' (K₁ Kβ‚‚ V : Type) := Kbar K₁ Kβ‚‚ β†’ V" }, { "name": "infix:50 \" β‰ β‚– \" => Key.keysUneq ", "content": "infix:50 \" β‰ β‚– \" => Key.keysUneq " }, { "name": "prefix:max \"!\" => UniqueTokenT", "content": "prefix:max \"!\" => UniqueTokenT" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "not_and_or", "module": "Mathlib.Logic.Basic" }, { "name": "congr_fun", "module": "Batteries.Logic" }, { "name": "List.ext_get_iff", "module": "Mathlib.Data.List.Basic" } ]
[ { "name": "le_of_ext_le", "content": "lemma le_of_ext_le {Ξ± : Type} [Preorder Ξ±] {v₁ vβ‚‚ : Vector Ξ± n}\n (h : βˆ€ i : Fin n, v₁.1[i] ≀ vβ‚‚.1[i]) : v₁ ≀ vβ‚‚" }, { "name": "mem_dict_iff_mem_keys", "content": "lemma mem_dict_iff_mem_keys {dict : Dict Ξ± Ο‰} : k ∈ dict ↔ k ∈ dict.keys" }, { "name": "eq_of_BalanceProof_le", "content": "lemma eq_of_BalanceProof_le (h : Ο€ ≀ Ο€') (h₁ : k ∈ Ο€) (hβ‚‚ : k ∈ Ο€') :\n ((Ο€ k).get h₁).2 = ((Ο€' k).get hβ‚‚).2" }, { "name": "mem_of_BalanceProof_le", "content": "lemma mem_of_BalanceProof_le (h : Ο€ ≀ Ο€') (h₁ : k ∈ Ο€) : k ∈ Ο€'" }, { "name": "notin_of_BalanceProof_le_notin", "content": "lemma notin_of_BalanceProof_le_notin (h : Ο€ ≀ Ο€') (h₁ : k βˆ‰ Ο€') : k βˆ‰ Ο€" }, { "name": "length_TransactionsInBlock_transfer", "content": "lemma length_TransactionsInBlock_transfer\n {b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }} :\n βˆ€ (π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V),\n (TransactionsInBlock_transfer π₁ b).length =\n (TransactionsInBlock_transfer Ο€β‚‚ b).length" }, { "name": "length_transactionsInBlock", "content": "lemma length_transactionsInBlock :\n (TransactionsInBlock π₁ b).length = (TransactionsInBlock Ο€β‚‚ b).length" }, { "name": "map_join_unnecessarily_specific", "content": "lemma map_join_unnecessarily_specific\n {Ξ± Ξ² Ξ³ Ξ΄ Pi : Type}\n [LE Ξ΄]\n [LE Pi]\n {l : List Ξ±}\n {P : (Ξ² Γ— Ξ³ Γ— Ξ΄) β†’ Prop}\n {Ο€ Ο€' : Pi}\n {f : Pi β†’ Ξ± β†’ List (Subtype P)}\n {i : β„•}\n (hβ‚€ : (List.length ∘ f Ο€) = (List.length ∘ f Ο€'))\n (h₁ : βˆ€ (a : Ξ±)\n (i : β„•) (h : i < (f Ο€ a).length),\n (f Ο€ a)[i].1.2.2 ≀ ((f Ο€' a)[i]'(by apply congr_fun at hβ‚€; aesop)).1.2.2)\n (h) :\n ((List.map (f Ο€) l).flatten[i]'h).1.2.2 ≀\n ((List.map (f Ο€') l).flatten[i]'(by aesop)).1.2.2" }, { "name": "map_eq_project_triple", "content": "lemma map_eq_project_triple {Ξ² Ξ³ Ξ΄ : Type}\n {s : Ξ²} {r : Ξ³} {v : Ξ΄}\n {i : β„•}\n {P : (Ξ² Γ— Ξ³ Γ— Ξ΄) β†’ Prop}\n {l : List (Subtype P)}\n {hβ‚€}\n {h : i < l.length} : \n l[i]'h = ⟨(s, r, v), hβ‚€βŸ© β†’ (l[i]'h).1.2.2 = v" }, { "name": "receiver_transactionsInBlocks", "content": "lemma receiver_transactionsInBlocks {bs : List (Block K₁ Kβ‚‚ C Sigma V)}\n {π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V} :\n (TransactionsInBlocks π₁ bs).map (Ξ» s ↦ s.1.2.1) =\n (TransactionsInBlocks Ο€β‚‚ bs).map (Ξ» s ↦ s.1.2.1)" }, { "name": "receiver_transactionsInBlock", "content": "lemma receiver_transactionsInBlock :\n (TransactionsInBlock π₁ b).map (Ξ» s ↦ s.1.2.1) =\n (TransactionsInBlock Ο€β‚‚ b).map (Ξ» s ↦ s.1.2.1)" }, { "name": "length_transactionsInBlocks", "content": "lemma length_transactionsInBlocks {bs : List (Block K₁ Kβ‚‚ C Sigma V)}\n {π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V} :\n (TransactionsInBlocks π₁ bs).length = (TransactionsInBlocks Ο€β‚‚ bs).length" }, { "name": "sender_transactionsInBlocks", "content": "lemma sender_transactionsInBlocks {bs : List (Block K₁ Kβ‚‚ C Sigma V)}\n {π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V} :\n (TransactionsInBlocks π₁ bs).map (Ξ» s ↦ s.1.1) =\n (TransactionsInBlocks Ο€β‚‚ bs).map (Ξ» s ↦ s.1.1)" }, { "name": "sender_transactionsInBlock", "content": "lemma sender_transactionsInBlock :\n (TransactionsInBlock π₁ b).map (Ξ» s ↦ s.1.1) =\n (TransactionsInBlock Ο€β‚‚ b).map (Ξ» s ↦ s.1.1)" } ]
[ { "name": "Intmax.length_of_TransactionsInBlocks", "content": "private abbrev length_of_TransactionsInBlocks (bs : List (Block K₁ Kβ‚‚ C Sigma V)) :\n { n : β„• // n = (TransactionsInBlocks (Classical.arbitrary _ : BalanceProof K₁ Kβ‚‚ C Pi V) bs).length } :=\n ⟨(TransactionsInBlocks (Classical.arbitrary _ : BalanceProof K₁ Kβ‚‚ C Pi V) bs).length, rfl⟩" }, { "name": "Intmax.TransactionsInBlocksFixed", "content": "private def TransactionsInBlocksFixed (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (bs : List (Block K₁ Kβ‚‚ C Sigma V)) :\n Vector (Ξ€ K₁ Kβ‚‚ V) (length_of_TransactionsInBlocks (Pi := Pi) bs).1 :=\n ⟨TransactionsInBlocks Ο€ bs, by admit /- proof elided -/\n ⟩" } ]
[ { "name": "Intmax.TransactionsInBlocksFixed_le_of_TransactionsInBlocks", "content": "lemma TransactionsInBlocksFixed_le_of_TransactionsInBlocks\n (h : βˆ€ i : Fin (length_of_TransactionsInBlocks bs).1,\n (TransactionsInBlocks Ο€ bs)[i]'(by blast with Ο€ i) ≀\n (TransactionsInBlocks Ο€' bs)[i]'(by blast with Ο€' i)) :\n TransactionsInBlocksFixed Ο€ bs ≀ TransactionsInBlocksFixed Ο€' bs" }, { "name": "Intmax.senderReceiver_transactionsInBlocks", "content": "lemma senderReceiver_transactionsInBlocks {s r v} {s' r' v'} {eq₁ eqβ‚‚} {i}\n (hβ‚€ : i < (TransactionsInBlocks Ο€ bs).length)\n (h₁ : (TransactionsInBlocks Ο€ bs)[i] = ⟨(s, r, v), eqβ‚βŸ©)\n (hβ‚‚ : (TransactionsInBlocks Ο€' bs)[i]'(by blast with Ο€) = ⟨(s', r', v'), eqβ‚‚βŸ©) :\n s = s' ∧ r = r'" }, { "name": "Intmax.delta_TransactionsInBlock_transfer", "content": "private lemma delta_TransactionsInBlock_transfer\n {b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }}\n (h : Ο€ ≀ Ο€') : \n βˆ€ i : β„•, (hlen : i < (TransactionsInBlock_transfer Ο€ b).length) β†’\n (TransactionsInBlock_transfer Ο€ b)[i]'hlen =\n (TransactionsInBlock_transfer Ο€' b)[i]'(by rwa [length_TransactionsInBlock_transfer _ Ο€]) ∨\n ((TransactionsInBlock_transfer Ο€ b)[i]'hlen).1.2.2.isNone" }, { "name": "Intmax.v_transactionsInBlocks", "content": "lemma v_transactionsInBlocks {s r v v'} {eq₁ eqβ‚‚} {i}\n (h : Ο€ ≀ Ο€')\n (hβ‚€ : i < (TransactionsInBlocks Ο€ Bstar).length)\n (h₁ : (TransactionsInBlocks Ο€ Bstar)[i] = ⟨(s, r, v), eqβ‚βŸ©)\n (hβ‚‚ : (TransactionsInBlocks Ο€' Bstar)[i]'(by blast with Ο€) = ⟨(s, r, v'), eqβ‚‚βŸ©) :\n v ≀ v'" } ]
import FVIntmax.Balance namespace Intmax open Mathlib noncomputable section Lemma4 section HicSuntDracones section variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [AddCommGroup V] [Lattice V] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} section HelperFunctionsToAppeaseLean open Mathlib private abbrev length_of_TransactionsInBlocks (bs : List (Block K₁ Kβ‚‚ C Sigma V)) : { n : β„• // n = (TransactionsInBlocks (Classical.arbitrary _ : BalanceProof K₁ Kβ‚‚ C Pi V) bs).length } := ⟨(TransactionsInBlocks (Classical.arbitrary _ : BalanceProof K₁ Kβ‚‚ C Pi V) bs).length, rfl⟩ open Lean.Elab.Tactic in private def TransactionsInBlocksFixed (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (bs : List (Block K₁ Kβ‚‚ C Sigma V)) : Vector (Ξ€ K₁ Kβ‚‚ V) (length_of_TransactionsInBlocks (Pi := Pi) bs).1 := ⟨TransactionsInBlocks Ο€ bs, by admit /- proof elided -/ ⟩ section variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} end end HelperFunctionsToAppeaseLean end section variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs Bstar : List (Block K₁ Kβ‚‚ C Sigma V)}
lemma monotone_TransactionsInBlocksFixed : Monotone Ξ» (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) ↦ TransactionsInBlocksFixed Ο€ Bstar :=
:= by intros Ο€ Ο€' h dsimp apply TransactionsInBlocksFixed_le_of_TransactionsInBlocks; rintro ⟨i, hi⟩; simp generalize eq : (TransactionsInBlocks Ο€ Bstar)[i]'(by blast with Ο€) = Tstar generalize eq' : (TransactionsInBlocks Ο€' Bstar)[i]'(by clear eq; blast with Ο€') = Tstar' rcases Tstar with ⟨⟨s, r, v⟩, hβ‚βŸ© rcases Tstar' with ⟨⟨s', r', v'⟩, hβ‚‚βŸ© obtain ⟨⟨⟩, ⟨⟩⟩ := senderReceiver_transactionsInBlocks _ eq eq'; simp exact v_transactionsInBlocks h _ eq eq'
9
73
false
Applied verif.
204
Intmax.compat_merge_of_compat
lemma compat_merge_of_compat : (βˆ€ Ο€', Ο€' ∈ Ο€s β†’ Ο€ <β‰…> Ο€') β†’ Ο€ <β‰…> (mergeR'' Ο€s .initial)
FVIntmax
FVIntmax/Theorem1.lean
[ "import FVIntmax.Lemma5", "import FVIntmax.Wheels.AuthenticatedDictionary", "import FVIntmax.Request", "import FVIntmax.AttackGame", "import FVIntmax.Wheels", "import FVIntmax.Propositions", "import Mathlib", "import FVIntmax.Lemma4", "import FVIntmax.Wheels.Dictionary", "import FVIntmax.Wheels.SignatureAggregation", "import FVIntmax.Lemma3" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "Finite", "module": "Mathlib.Data.Finite.Defs" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" } ]
[ { "name": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b", "content": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b" }, { "name": "notation:51 π₁:52 \" <β‰…> \" Ο€β‚‚:52 => BalanceProof.compat π₁ Ο€β‚‚", "content": "notation:51 π₁:52 \" <β‰…> \" Ο€β‚‚:52 => BalanceProof.compat π₁ Ο€β‚‚" }, { "name": "notation:65 π₁:65 \" <+> \" Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚", "content": "notation:65 π₁:65 \" <+> \" Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚" }, { "name": "BalanceProof", "content": "abbrev BalanceProof (K₁ Kβ‚‚ : Type) [Finite K₁] [Finite Kβ‚‚]\n (C Pi V : Type) [PreWithZero V] : Type :=\n Dict (C Γ— Kβ‚‚) ((Pi Γ— ExtraDataT) Γ— TransactionBatch K₁ Kβ‚‚ V) " }, { "name": "TransactionBatch", "content": "abbrev TransactionBatch (K₁ : Type) [Finite K₁]\n (Kβ‚‚ : Type) [Finite Kβ‚‚]\n (V : Type) [PreWithZero V] :=\n Key K₁ Kβ‚‚ β†’ Vβ‚Š" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "Merge", "content": "def Merge (D₁ Dβ‚‚ : Dict Ξ± Ο‰) : Dict Ξ± Ο‰ := D\n where D := Ξ» x ↦ First (D₁ x) (Dβ‚‚ x)" }, { "name": "First", "content": "def First (x₁ xβ‚‚ : Option Ξ±) : Option Ξ± :=\n match x₁, xβ‚‚ with\n | .some x, .none => .some x\n | .some x, .some _ => .some x\n | .none, .some y => .some y\n | .none, .none => .none" }, { "name": "BalanceProof.initial", "content": "def BalanceProof.initial : BalanceProof K₁ Kβ‚‚ C Pi V := Ξ» _ ↦ .none" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Merge_assoc", "content": "lemma Merge_assoc {D₃ : Dict Ξ± Ο‰} :\n Merge (Merge D₁ Dβ‚‚) D₃ = Merge D₁ (Merge Dβ‚‚ D₃)" } ]
[ { "name": "Intmax.mergeR''", "content": "def mergeR'' (Ο€s : List (BalanceProof K₁ Kβ‚‚ C Pi V)) (acc : BalanceProof K₁ Kβ‚‚ C Pi V) : BalanceProof K₁ Kβ‚‚ C Pi V :=\n match Ο€s with\n | [] => acc\n | Ο€ :: Ο€s => Dict.Merge acc (mergeR'' Ο€s Ο€)" }, { "name": "Intmax.BalanceProof.compat", "content": "def BalanceProof.compat (π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V) : Prop :=\n βˆ€ k, π₁ k β‰  none ∧ Ο€β‚‚ k β‰  none β†’ π₁ k β‰… Ο€β‚‚ k" } ]
[ { "name": "Intmax.merge_lem_aux", "content": "private lemma merge_lem_aux :\n mergeR'' (Ο€ :: Ο€s) acc = acc <+> Ο€ <+> (mergeR'' Ο€s BalanceProof.initial)" }, { "name": "Intmax.merge_lem", "content": "lemma merge_lem :\n mergeR'' (Ο€ :: Ο€s) BalanceProof.initial = Ο€ <+> (mergeR'' Ο€s BalanceProof.initial)" }, { "name": "Intmax.compat_lem", "content": "lemma compat_lem {Ο€ Ο€' Ο€'': BalanceProof K₁ Kβ‚‚ C Pi V} :\n Ο€ <β‰…> Ο€' β†’ Ο€ <β‰…> Ο€'' β†’ Ο€ <β‰…> (Ο€' <+> Ο€'')" } ]
import FVIntmax.AttackGame import FVIntmax.Lemma3 import FVIntmax.Lemma4 import FVIntmax.Lemma5 import FVIntmax.Propositions import FVIntmax.Request import FVIntmax.Wheels import FVIntmax.Wheels.AuthenticatedDictionary import FVIntmax.Wheels.SignatureAggregation import Mathlib namespace Intmax open Classical noncomputable section Intmax noncomputable section theorem1 section AttackGame variable {Sigma Pi M : Type} {C : Type} [Nonempty C] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] {K₁ : Type} [Nonempty K₁] [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {Kβ‚š : Type} [Nonempty Kβ‚š] {Kβ‚› : Type} [Nonempty Kβ‚›] def mergeR'' (Ο€s : List (BalanceProof K₁ Kβ‚‚ C Pi V)) (acc : BalanceProof K₁ Kβ‚‚ C Pi V) : BalanceProof K₁ Kβ‚‚ C Pi V := match Ο€s with | [] => acc | Ο€ :: Ο€s => Dict.Merge acc (mergeR'' Ο€s Ο€) section MergeLemmas variable {acc Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V} {Ο€s Ο€s : List (BalanceProof K₁ Kβ‚‚ C Pi V)} end MergeLemmas def BalanceProof.compat (π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V) : Prop := βˆ€ k, π₁ k β‰  none ∧ Ο€β‚‚ k β‰  none β†’ π₁ k β‰… Ο€β‚‚ k notation:51 π₁:52 " <β‰…> " Ο€β‚‚:52 => BalanceProof.compat π₁ Ο€β‚‚ notation:65 π₁:65 " <+> " Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚ section Compat variable {π₁ Ο€β‚‚ π₃ : BalanceProof K₁ Kβ‚‚ C Pi V} end Compat section MergeLemmas variable {Ο€ acc : BalanceProof K₁ Kβ‚‚ C Pi V} {Ο€s : List (BalanceProof K₁ Kβ‚‚ C Pi V)} end MergeLemmas variable [AD : ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi] section MergeLemmas variable {Ο€ acc : BalanceProof K₁ Kβ‚‚ C Pi V} {Ο€s : List (BalanceProof K₁ Kβ‚‚ C Pi V)}
lemma compat_merge_of_compat : (βˆ€ Ο€', Ο€' ∈ Ο€s β†’ Ο€ <β‰…> Ο€') β†’ Ο€ <β‰…> (mergeR'' Ο€s .initial) :=
:= by induction Ο€s generalizing Ο€ with | nil => intros Ο€ unfold BalanceProof.compat BalanceProof.initial simp | cons Ο€ Ο€s ih => intros Ο€_1 h rw [merge_lem] apply compat_lem <;> aesop
5
22
false
Applied verif.
205
Intmax.aggregateDeposits_cons
@[simp] lemma aggregateDeposits_cons {hd} {tl : List (Block K₁ Kβ‚‚ C Sigma V)} : aggregateDeposits (hd :: tl) = (if h : hd.isDepositBlock then (hd.getDeposit h).2.1 else 0) + aggregateDeposits tl
FVIntmax
FVIntmax/AttackGame.lean
[ "import FVIntmax.Wheels.AuthenticatedDictionary", "import FVIntmax.Request", "import FVIntmax.Block", "import FVIntmax.Wheels.SignatureAggregation", "import FVIntmax.BalanceProof", "import FVIntmax.Wheels" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Sigma", "module": "Init.Core" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" }, { "name": "Finset.range", "module": "Mathlib.Data.Finset.Range" } ]
[ { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "Scontract", "content": "abbrev Scontract (K₁ Kβ‚‚ V : Type) [PreWithZero V] (C Sigma : Type) :=\n List (Block K₁ Kβ‚‚ C Sigma V)" }, { "name": "Block", "content": "inductive Block (K₁ Kβ‚‚ : Type) (C Sigma : Type) (V : Type) [PreWithZero V] where\n \n | deposit (recipient : Kβ‚‚) (amount : Vβ‚Š)\n \n | transfer (aggregator : K₁) (extradata : ExtraDataT) (commitment : C) (senders : List Kβ‚‚) (sigma : Sigma)\n \n | withdrawal (withdrawals : K₁ β†’ Vβ‚Š)" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "isDepositBlock", "content": "abbrev isDepositBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.deposit _ _) " }, { "name": "getDeposit", "content": "def getDeposit (b : Block K₁ Kβ‚‚ C Sigma V) (_h : b.isDepositBlock) : Kβ‚‚ Γ— Vβ‚Š :=\n match b with | deposit r v => (r, v)" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "Finset.mem_range", "module": "Mathlib.Data.Finset.Range" }, { "name": "Finset.sum_bij", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Defs" }, { "name": "Finset.sum_dite_of_true", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Piecewise" }, { "name": "Finset.sum_eq_sum_diff_singleton_add", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Piecewise" }, { "name": "Finset.sum_fin_eq_sum_range", "module": "Mathlib.Data.Fintype.BigOperators" }, { "name": "Finset.univ_eq_attach", "module": "Mathlib.Data.Fintype.Sets" }, { "name": "List.getElem_cons_zero", "module": "Init.GetElem" }, { "name": "add_comm", "module": "Mathlib.Algebra.Group.Defs" }, { "name": "dif_pos", "module": "Init.Core" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Intmax.aggregateDeposits", "content": "def aggregateDeposits (Οƒ : Scontract K₁ Kβ‚‚ V C Sigma) : V :=\n βˆ‘ i : Fin Οƒ.length,\n if h : Οƒ[i].isDepositBlock\n then (Οƒ[i.1].getDeposit h).2.1\n else 0" }, { "name": "Intmax.reindex", "content": "@[simp]\nprivate def reindex : (a : β„•) β†’ a ∈ Finset.range (k + 1) \\ {0} β†’ β„• :=\n Ξ» a _ ↦ a.pred" } ]
[ { "name": "Intmax.reindex_mem", "content": "private lemma reindex_mem :\n βˆ€ (a : β„•) (ha : a ∈ Finset.range (k + 1) \\ {0}), reindex a ha ∈ Finset.range k" }, { "name": "Intmax.reindex_inj", "content": "private lemma reindex_inj :\n βˆ€ (a₁ : β„•) (ha₁ : a₁ ∈ Finset.range (k + 1) \\ {0})\n (aβ‚‚ : β„•) (haβ‚‚ : aβ‚‚ ∈ Finset.range (k + 1) \\ {0}),\n reindex a₁ ha₁ = reindex aβ‚‚ haβ‚‚ β†’ a₁ = aβ‚‚" } ]
import FVIntmax.Wheels.AuthenticatedDictionary import FVIntmax.Wheels.SignatureAggregation import FVIntmax.BalanceProof import FVIntmax.Block import FVIntmax.Request import FVIntmax.Wheels namespace Intmax noncomputable section Intmax section RollupContract open Classical section variable {C : Type} [Nonempty C] {V : Type} [Lattice V] [AddCommGroup V] {K₁ : Type} [Finite K₁] [Nonempty K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] {Sigma : Type} [ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi] [SA : SignatureAggregation (C Γ— K₁ Γ— ExtraDataT) Kβ‚‚ Kβ‚›T Sigma] end section variable {C : Type} {V : Type} [Lattice V] [AddCommGroup V] {K₁ : Type} [Finite K₁] {Kβ‚‚ : Type} {Sigma : Type} {block : Block K₁ Kβ‚‚ C Sigma V} {v : V} section Lemmas end Lemmas namespace Scontract section variable [LinearOrder K₁] [Nonempty K₁] [LinearOrder Kβ‚‚] [Finite Kβ‚‚] [Nonempty C] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] [ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi] [SignatureAggregation (C Γ— K₁ Γ— ExtraDataT) Kβ‚‚ Kβ‚›T Sigma] section appendBlock variable {Οƒ : Scontract K₁ Kβ‚‚ V C Sigma} {request : Request K₁ Kβ‚‚ C Sigma Pi V} end appendBlock end section variable [LinearOrder K₁] [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {Οƒ : Scontract K₁ Kβ‚‚ V C Sigma} {request : Request K₁ Kβ‚‚ C Sigma Pi V} [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] end end Scontract end end RollupContract section AttackGameDefs variable {K₁ : Type} [Finite K₁] [LinearOrder K₁] [Nonempty K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] {Sigma : Type} {C : Type} [Nonempty C] [ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi] [SignatureAggregation (C Γ— K₁ Γ— ExtraDataT) Kβ‚‚ Kβ‚›T Sigma] (requests : List (Request K₁ Kβ‚‚ C Sigma Pi V)) (Οƒ : Scontract K₁ Kβ‚‚ V C Sigma) def aggregateDeposits (Οƒ : Scontract K₁ Kβ‚‚ V C Sigma) : V := βˆ‘ i : Fin Οƒ.length, if h : Οƒ[i].isDepositBlock then (Οƒ[i.1].getDeposit h).2.1 else 0 end AttackGameDefs section AttackGameLemmas variable {K₁ Kβ‚‚ Sigma C : Type} {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi] section computeBalanceSum variable {k : β„•} @[simp] private def reindex : (a : β„•) β†’ a ∈ Finset.range (k + 1) \ {0} β†’ β„• := Ξ» a _ ↦ a.pred end computeBalanceSum
@[simp] lemma aggregateDeposits_cons {hd} {tl : List (Block K₁ Kβ‚‚ C Sigma V)} : aggregateDeposits (hd :: tl) = (if h : hd.isDepositBlock then (hd.getDeposit h).2.1 else 0) + aggregateDeposits tl :=
:= by simp [aggregateDeposits] rw [ Finset.sum_fin_eq_sum_range, Finset.sum_eq_sum_diff_singleton_add (i := 0), dif_pos (show 0 < tl.length + 1 by omega) ] simp_rw [List.getElem_cons_zero (h := _)]; case h => exact Finset.mem_range.2 (by omega) let F : β„• β†’ V := Ξ» i ↦ if h : i < tl.length then if h_1 : tl[i].isDepositBlock = true then (tl[i].getDeposit h_1).2 else 0 else 0 rw [Finset.sum_bij (t := Finset.range tl.length) (g := F) (i := reindex) (hi := reindex_mem) (i_inj := reindex_inj) (i_surj := Ξ» b hb ↦ by use b.succ; simp; exact Finset.mem_range.1 hb) (h := Ξ» n hn ↦ by simp at hn; simp [hn] rcases n with _ | n <;> [omega; simp [F, reindex]] nth_rw 2 [dif_pos (by rcases hn with ⟨hn, _⟩; omega)])] unfold F rw [Finset.sum_dite_of_true (Ξ» _ ↦ (Finset.mem_range.1 Β·)), Finset.sum_fin_eq_sum_range, Finset.univ_eq_attach] nth_rw 2 [Finset.sum_dite_of_true]; case h => exact Ξ» _ ↦ (Finset.mem_range.1 Β·) rw [add_comm]; simp
5
28
false
Applied verif.
206
Intmax.f_transfer_source''
lemma f_transfer_source'' (h : b.isTransferBlock) (h₁ : T ∈ TransactionsInBlock Ο€ b) : (f Οƒ T) .Source = Οƒ .Source := f_transfer_source ⟨⟨b, h⟩, hβ‚βŸ©
FVIntmax
FVIntmax/Balance.lean
[ "import FVIntmax.BalanceProof", "import FVIntmax.Wheels", "import FVIntmax.Propositions", "import Mathlib", "import FVIntmax.Key", "import FVIntmax.Block", "import Mathlib.Algebra.Group.Int", "import FVIntmax.Wheels.Dictionary", "import FVIntmax.State", "import FVIntmax.Transaction" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Finite", "module": "Mathlib.Data.Finite.Defs" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" }, { "name": "IsGLB", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "And", "module": "Init.Prelude" }, { "name": "IsGreatest", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "lowerBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "upperBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "InfSet", "module": "Mathlib.Order.SetNotation" }, { "name": "iInf", "module": "Mathlib.Order.SetNotation" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "Prod.mk", "module": "Init.Prelude" }, { "name": "Subtype", "module": "Init.Prelude" }, { "name": "Subtype.mk", "module": "Init.Prelude" }, { "name": "Sum", "module": "Init.Core" }, { "name": "Sum.inl", "module": "Init.Core" }, { "name": "Sum.inr", "module": "Init.Core" }, { "name": "reduceCtorEq", "module": "Lean.Meta.Tactic.Simp.BuiltinSimprocs.Core" }, { "name": "Set.range", "module": "Mathlib.Data.Set.Operations" } ]
[ { "name": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$", "content": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$b, by admit /- proof elided -/\n⟩)" }, { "name": "Block", "content": "inductive Block (K₁ Kβ‚‚ : Type) (C Sigma : Type) (V : Type) [PreWithZero V] where\n \n | deposit (recipient : Kβ‚‚) (amount : Vβ‚Š)\n \n | transfer (aggregator : K₁) (extradata : ExtraDataT) (commitment : C) (senders : List Kβ‚‚) (sigma : Sigma)\n \n | withdrawal (withdrawals : K₁ β†’ Vβ‚Š)" }, { "name": "isWithdrawalBlock", "content": "abbrev isWithdrawalBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.withdrawal _)" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "attach", "content": "noncomputable def attach (Ξ± : Type) [Finite Ξ±] : UniquelyIndexed Ξ± :=\n have := Finite.exists_equiv_fin Ξ±\n this.choose_spec.some.toEmbedding" }, { "name": "UniquelyIndexed", "content": "abbrev UniquelyIndexed (Ξ± : Type) [Finite Ξ±] : Type := Ξ± β†ͺ !Ξ±" }, { "name": "UniqueTokenT", "content": "abbrev UniqueTokenT (Ξ± : Type) [Finite Ξ±] : Type := Fin (Finite.exists_equiv_fin Ξ± |>.choose)" }, { "name": "Ξ€", "content": "abbrev Ξ€ (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { Ο„ : Ξ€' K₁ Kβ‚‚ V // Ο„.isValid }" }, { "name": "Ξ€'", "content": "abbrev Ξ€' (K₁ Kβ‚‚ V : Type) [PreWithZero V] := Kbar K₁ Kβ‚‚ Γ— Kbar K₁ Kβ‚‚ Γ— Option Vβ‚Š" }, { "name": "Kbar", "content": "inductive Kbar (K₁ Kβ‚‚ : Type) where\n | key (k : Key K₁ Kβ‚‚)\n | Source\nderiving DecidableEq" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "BalanceProof", "content": "abbrev BalanceProof (K₁ Kβ‚‚ : Type) [Finite K₁] [Finite Kβ‚‚]\n (C Pi V : Type) [PreWithZero V] : Type :=\n Dict (C Γ— Kβ‚‚) ((Pi Γ— ExtraDataT) Γ— TransactionBatch K₁ Kβ‚‚ V) " }, { "name": "TransactionBatch", "content": "abbrev TransactionBatch (K₁ : Type) [Finite K₁]\n (Kβ‚‚ : Type) [Finite Kβ‚‚]\n (V : Type) [PreWithZero V] :=\n Key K₁ Kβ‚‚ β†’ Vβ‚Š" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "lexLe", "content": "def lexLe (a b : Kβ‚‚ Γ— Key K₁ Kβ‚‚) : Prop :=\n a.1 < b.1 ∨ (a.1 = b.1 ∧ a.2 ≀ b.2)" }, { "name": "isTransferBlock", "content": "abbrev isTransferBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.transfer _ _ _ _ _)" }, { "name": "keys", "content": "def keys (m : Dict Ξ± Ο‰) : Set Ξ± := { x | Dict.is_mem m x }" }, { "name": "Dict.is_mem", "content": "def Dict.is_mem (m : Dict Ξ± Ο‰) (x : Ξ±) : Prop := (m x).isSome" }, { "name": "keys", "content": "abbrev keys (ct : CommitT C K Pi) := ct.dict.keys" }, { "name": "CommitT", "content": "structure CommitT (C K Pi : Type) where\n commitment : C\n dict : Dict K Pi" }, { "name": "keysUneq", "content": "abbrev keysUneq (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) : Prop :=\n match k with\n | .inl _ => True\n | .inr kβ‚‚' => kβ‚‚ β‰  kβ‚‚'" }, { "name": "isDepositBlock", "content": "abbrev isDepositBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.deposit _ _) " }, { "name": "S", "content": "abbrev S (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { s : S' K₁ Kβ‚‚ V // s.isValid }" }, { "name": "S'", "content": "abbrev S' (K₁ Kβ‚‚ V : Type) := Kbar K₁ Kβ‚‚ β†’ V" }, { "name": "Ξ€c", "content": "abbrev Ξ€c (K₁ Kβ‚‚ V : Type) [PreWithZero V] : Type := { Ο„ : Ξ€ K₁ Kβ‚‚ V // Ο„.isComplete }" }, { "name": "isComplete", "content": "def isComplete (Ο„ : Ξ€ K₁ Kβ‚‚ V) :=\n match Ο„ with | ⟨(_, _, v), _⟩ => v.isSome" }, { "name": "value", "content": "def value (Ο„ : Ξ€ K₁ Kβ‚‚ V) : Option Vβ‚Š := Ο„.1.2.2" }, { "name": "infix:50 \" β‰ β‚– \" => Key.keysUneq ", "content": "infix:50 \" β‰ β‚– \" => Key.keysUneq " }, { "name": "prefix:max \"!\" => UniqueTokenT", "content": "prefix:max \"!\" => UniqueTokenT" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "Set.image_eq_range", "module": "Mathlib.Data.Set.Image" }, { "name": "if_pos", "module": "Init.Core" }, { "name": "Finset.mem_filter", "module": "Mathlib.Data.Finset.Filter" }, { "name": "Finset.mem_sort", "module": "Mathlib.Data.Finset.Sort" }, { "name": "Finset.mem_univ", "module": "Mathlib.Data.Fintype.Defs" }, { "name": "List.mem_attach", "module": "Init.Data.List.Attach" }, { "name": "List.mem_map", "module": "Init.Data.List.Lemmas" }, { "name": "and_false", "module": "Init.SimpLemmas" }, { "name": "and_true", "module": "Init.SimpLemmas" }, { "name": "exists_and_left", "module": "Init.PropLemmas" }, { "name": "exists_const", "module": "Init.PropLemmas" }, { "name": "exists_eq", "module": "Init.PropLemmas" }, { "name": "exists_eq_right", "module": "Init.PropLemmas" }, { "name": "exists_eq_right_right", "module": "Init.PropLemmas" }, { "name": "exists_false", "module": "Init.PropLemmas" }, { "name": "exists_prop", "module": "Init.PropLemmas" }, { "name": "exists_true_left", "module": "Init.PropLemmas" }, { "name": "false_or", "module": "Init.SimpLemmas" }, { "name": "ite_not", "module": "Init.PropLemmas" }, { "name": "or_false", "module": "Init.SimpLemmas" }, { "name": "true_and", "module": "Init.SimpLemmas" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Intmax.TransactionsInBlock_deposit", "content": "def TransactionsInBlock_deposit\n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/\n ⟩]\n | .withdrawal .. | .transfer .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock_transfer", "content": "def TransactionsInBlock_transfer \n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .transfer _ _ commitment S _ =>\n \n let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) }\n let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe \n \n let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š :=\n if s βˆ‰ S\n then .some 0\n else \n if h : (commitment, s) ∈ Ο€.keys\n then let (_, t) := Ο€[(commitment, s)]\n t r\n else .none\n sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/\n ⟩\n | .deposit .. | .withdrawal .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock_withdrawal", "content": "def TransactionsInBlock_withdrawal \n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .withdrawal withdrawals =>\n \n let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·)\n k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/\n ⟩\n | .deposit r v | .transfer .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock", "content": "def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := \n match h : b with\n | .deposit .. => TransactionsInBlock_deposit β†ͺb\n | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb\n | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb" }, { "name": "Intmax.e", "content": "def e (i : Kbar K₁ Kβ‚‚) : Kbar K₁ Kβ‚‚ β†’ β„€ := Ξ» j ↦ if i = j then 1 else 0" }, { "name": "Intmax.fc", "content": "def fc (Ο„cXb : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨λ k : Kbar K₁ Kβ‚‚ ↦\n match Ο„cXb with\n | ⟨⟨⟨⟨s, r, v⟩, _⟩, hΟ„βŸ©, b⟩ =>\n let v' := v' (v.get hΟ„) b s\n b k + (e r - e s) k β€’ v',\n by admit /- proof elided -/\n ⟩" }, { "name": "Intmax.boundedBelow", "content": "abbrev boundedBelow (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) :=\n { a : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V | (T, b) ≀ (↑a.1, a.2) }" }, { "name": "Intmax.V'", "content": "def V' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) : Set V :=\n { v : V | v ∈ (fc Β· k) '' boundedBelow b T }" }, { "name": "Intmax.f'", "content": "def f' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := \n ⟨\n Ξ» k ↦\n match h : T with\n | ⟨(_, _, .some _), hT⟩ => fc (⟨T, by admit /- proof elided -/\n ⟩, b) k\n | ⟨(s, _, .none), _⟩ => if k = s then 0 else b k,\n by admit /- proof elided -/\n ⟩" }, { "name": "Intmax.exists_inf", "content": "def exists_inf (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : { s : S K₁ Kβ‚‚ V // βˆ€ k, IsGLB (V' b T k) (s k) } :=\n ⟨\n f' b T,\n Ξ» k ↦\n have f'_codomain : (f' b T) k ∈ V' b T k := by admit /- proof elided -/\n ⟩" }, { "name": "Intmax.infV", "content": "def infV (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) :\n InfSet V where\n sInf := Ξ» s ↦ if s = V' b T k\n then (exists_inf b T).1 k\n else 0" }, { "name": "Intmax.f", "content": "def f (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨\n Ξ» k ↦\n have : InfSet V := infV b T k\n β¨… x : boundedBelow b T, fc x.1 k,\n by admit /- proof elided -/\n ⟩" } ]
[ { "name": "Intmax.V'_eq_range", "content": "private lemma V'_eq_range {b : S K₁ Kβ‚‚ V} {T : Ξ€ K₁ Kβ‚‚ V} {k : Kbar K₁ Kβ‚‚} :\n V' b T k =\n Set.range Ξ» (x : { x : (Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V) // (T, b) ≀ (↑x.1, x.2) }) ↦ fc ↑x k" }, { "name": "Intmax.f_eq_f'", "content": "lemma f_eq_f' : f = f' (K₁ := K₁) (Kβ‚‚ := Kβ‚‚) (V := V)" }, { "name": "Intmax.f_transfer_source", "content": "lemma f_transfer_source\n (h : βˆƒ block : {b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock},\n T ∈ TransactionsInBlock Ο€ block.1) :\n (f Οƒ T) .Source = Οƒ .Source" } ]
import Mathlib import Mathlib.Algebra.Group.Int import FVIntmax.BalanceProof import FVIntmax.Block import FVIntmax.Key import FVIntmax.Propositions import FVIntmax.State import FVIntmax.Transaction import FVIntmax.Wheels import FVIntmax.Wheels.Dictionary namespace Intmax noncomputable section open Classical section Balance variable {Pi K₁ Kβ‚‚ V C Sigma : Type} section Extraction section Deposit variable [PreWithZero V] def TransactionsInBlock_deposit (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/ ⟩] | .withdrawal .. | .transfer .. => by admit /- proof elided -/ end Deposit section Transfer variable [Finite K₁] [Finite Kβ‚‚] [LinearOrder K₁] [LinearOrder Kβ‚‚] [PreWithZero V] def TransactionsInBlock_transfer (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .transfer _ _ commitment S _ => let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) } let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š := if s βˆ‰ S then .some 0 else if h : (commitment, s) ∈ Ο€.keys then let (_, t) := Ο€[(commitment, s)] t r else .none sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/ ⟩ | .deposit .. | .withdrawal .. => by admit /- proof elided -/ end Transfer section Withdrawal variable [LinearOrder K₁] [Finite K₁] [PreWithZero V] def TransactionsInBlock_withdrawal (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .withdrawal withdrawals => let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·) k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/ ⟩ | .deposit r v | .transfer .. => by admit /- proof elided -/ end Withdrawal variable [Finite K₁] [LinearOrder K₁] [Finite Kβ‚‚] [LinearOrder Kβ‚‚] [PreWithZero V] {b : Block K₁ Kβ‚‚ C Sigma V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} {π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V} def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b with | .deposit .. => TransactionsInBlock_deposit β†ͺb | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb end Extraction section e def e (i : Kbar K₁ Kβ‚‚) : Kbar K₁ Kβ‚‚ β†’ β„€ := Ξ» j ↦ if i = j then 1 else 0 variable {i j : Kbar K₁ Kβ‚‚} end e section WithStructuredTypes section v' variable [Zero V] [Lattice V] -- NB `PreWithZero V` is implied as `CompleteLattice V` gives `Preorder V`. variable {v : Vβ‚Š} {b : S K₁ Kβ‚‚ V} {s : Kbar K₁ Kβ‚‚} end v' section Fc variable [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] def fc (Ο„cXb : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := ⟨λ k : Kbar K₁ Kβ‚‚ ↦ match Ο„cXb with | ⟨⟨⟨⟨s, r, v⟩, _⟩, hΟ„βŸ©, b⟩ => let v' := v' (v.get hΟ„) b s b k + (e r - e s) k β€’ v', by admit /- proof elided -/ ⟩ variable {Ο„c : Ξ€c K₁ Kβ‚‚ V} {b : S K₁ Kβ‚‚ V} end Fc section Order variable [Lattice V] [AddCommGroup V] end Order section BoundedBelow variable [Lattice V] [AddCommGroup V] abbrev boundedBelow (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) := { a : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V | (T, b) ≀ (↑a.1, a.2) } end BoundedBelow section LGroup variable [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] def V' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) : Set V := { v : V | v ∈ (fc Β· k) '' boundedBelow b T } section f def f' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := ⟨ Ξ» k ↦ match h : T with | ⟨(_, _, .some _), hT⟩ => fc (⟨T, by admit /- proof elided -/ ⟩, b) k | ⟨(s, _, .none), _⟩ => if k = s then 0 else b k, by admit /- proof elided -/ ⟩ def exists_inf (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : { s : S K₁ Kβ‚‚ V // βˆ€ k, IsGLB (V' b T k) (s k) } := ⟨ f' b T, Ξ» k ↦ have f'_codomain : (f' b T) k ∈ V' b T k := by admit /- proof elided -/ ⟩ def infV (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) : InfSet V where sInf := Ξ» s ↦ if s = V' b T k then (exists_inf b T).1 k else 0 def f (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := ⟨ Ξ» k ↦ have : InfSet V := infV b T k β¨… x : boundedBelow b T, fc x.1 k, by admit /- proof elided -/ ⟩ end f section fStar variable {s : S K₁ Kβ‚‚ V} end fStar variable [Finite K₁] [LinearOrder K₁] [Finite Kβ‚‚] [LinearOrder Kβ‚‚] section LocalProperties variable {Οƒ : S K₁ Kβ‚‚ V} {Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V} {T : Ξ€ K₁ Kβ‚‚ V} {b : Block K₁ Kβ‚‚ C Sigma V} {Sigma : Type}
lemma f_transfer_source'' (h : b.isTransferBlock) (h₁ : T ∈ TransactionsInBlock Ο€ b) : (f Οƒ T) .Source = Οƒ .Source :=
:= f_transfer_source ⟨⟨b, h⟩, hβ‚βŸ©
6
90
false
Applied verif.
207
Intmax.sum_f_le_sum
lemma sum_f_le_sum : βˆ‘ (k : Kbar K₁ Kβ‚‚), f b T k ≀ βˆ‘ (k : Kbar K₁ Kβ‚‚), b k
FVIntmax
FVIntmax/Lemma3.lean
[ "import FVIntmax.Balance" ]
[ { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "IsGLB", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "And", "module": "Init.Prelude" }, { "name": "IsGreatest", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "lowerBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "upperBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "InfSet", "module": "Mathlib.Order.SetNotation" }, { "name": "iInf", "module": "Mathlib.Order.SetNotation" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" } ]
[ { "name": "isComplete", "content": "def isComplete (Ο„ : Ξ€ K₁ Kβ‚‚ V) :=\n match Ο„ with | ⟨(_, _, v), _⟩ => v.isSome" }, { "name": "Ξ€", "content": "abbrev Ξ€ (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { Ο„ : Ξ€' K₁ Kβ‚‚ V // Ο„.isValid }" }, { "name": "Ξ€'", "content": "abbrev Ξ€' (K₁ Kβ‚‚ V : Type) [PreWithZero V] := Kbar K₁ Kβ‚‚ Γ— Kbar K₁ Kβ‚‚ Γ— Option Vβ‚Š" }, { "name": "Kbar", "content": "inductive Kbar (K₁ Kβ‚‚ : Type) where\n | key (k : Key K₁ Kβ‚‚)\n | Source\nderiving DecidableEq" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "Ξ€c", "content": "abbrev Ξ€c (K₁ Kβ‚‚ V : Type) [PreWithZero V] : Type := { Ο„ : Ξ€ K₁ Kβ‚‚ V // Ο„.isComplete }" }, { "name": "V'", "content": "def V' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) : Set V :=\n { v : V | v ∈ (fc Β· k) '' boundedBelow b T }" }, { "name": "boundedBelow", "content": "abbrev boundedBelow (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) :=\n { a : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V | (T, b) ≀ (↑a.1, a.2) }" }, { "name": "S", "content": "abbrev S (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { s : S' K₁ Kβ‚‚ V // s.isValid }" }, { "name": "S'", "content": "abbrev S' (K₁ Kβ‚‚ V : Type) := Kbar K₁ Kβ‚‚ β†’ V" }, { "name": "fc", "content": "def fc (Ο„cXb : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨λ k : Kbar K₁ Kβ‚‚ ↦\n match Ο„cXb with\n | ⟨⟨⟨⟨s, r, v⟩, _⟩, hΟ„βŸ©, b⟩ =>\n let v' := v' (v.get hΟ„) b s\n b k + (e r - e s) k β€’ v',\n by admit /- proof elided -/\n ⟩" }, { "name": "e", "content": "def e (i : Kbar K₁ Kβ‚‚) : Kbar K₁ Kβ‚‚ β†’ β„€ := Ξ» j ↦ if i = j then 1 else 0" }, { "name": "f", "content": "def f (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨\n Ξ» k ↦\n have : InfSet V := infV b T k\n β¨… x : boundedBelow b T, fc x.1 k,\n by admit /- proof elided -/\n ⟩" }, { "name": "infV", "content": "def infV (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) :\n InfSet V where\n sInf := Ξ» s ↦ if s = V' b T k\n then (exists_inf b T).1 k\n else 0" }, { "name": "exists_inf", "content": "def exists_inf (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : { s : S K₁ Kβ‚‚ V // βˆ€ k, IsGLB (V' b T k) (s k) } :=\n ⟨\n f' b T,\n Ξ» k ↦\n have f'_codomain : (f' b T) k ∈ V' b T k := by admit /- proof elided -/\n ⟩" }, { "name": "f'", "content": "def f' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := \n ⟨\n Ξ» k ↦\n match h : T with\n | ⟨(_, _, .some _), hT⟩ => fc (⟨T, by admit /- proof elided -/\n ⟩, b) k\n | ⟨(s, _, .none), _⟩ => if k = s then 0 else b k,\n by admit /- proof elided -/\n ⟩" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "Finset.sum_add_distrib", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Basic" }, { "name": "Finset.sum_smul", "module": "Mathlib.Algebra.Module.BigOperators" }, { "name": "Finset.sum_le_sum", "module": "Mathlib.Algebra.Order.BigOperators.Group.Finset" }, { "name": "Set.mem_image", "module": "Mathlib.Data.Set.Operations" } ]
[ { "name": "f_IsGLB_of_V'", "content": "lemma f_IsGLB_of_V' {b : S K₁ Kβ‚‚ V} {T : Ξ€ K₁ Kβ‚‚ V} {k : Kbar K₁ Kβ‚‚} :\n IsGLB (V' b T k) (f b T k)" } ]
[]
[ { "name": "Intmax.sum_fc_eq_sum", "content": "@[simp]\nlemma sum_fc_eq_sum : βˆ‘ (k : Kbar K₁ Kβ‚‚), fc (Tc, b) k = βˆ‘ (k : Kbar K₁ Kβ‚‚), b k" } ]
import FVIntmax.Balance namespace Intmax section Lemma3 variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] variable {Tc : Ξ€c K₁ Kβ‚‚ V} {T : Ξ€ K₁ Kβ‚‚ V} {b : S K₁ Kβ‚‚ V} {Tstar : List (Ξ€ K₁ Kβ‚‚ V)}
lemma sum_f_le_sum : βˆ‘ (k : Kbar K₁ Kβ‚‚), f b T k ≀ βˆ‘ (k : Kbar K₁ Kβ‚‚), b k :=
:= by by_cases eq : T.isComplete Β· conv_rhs => rw [←sum_fc_eq_sum (Tc := ⟨T, eq⟩)] refine' Finset.sum_le_sum (Ξ» k _ ↦ _) have fcInV' : fc (⟨T, eq⟩, b) k ∈ V' b T k := by dsimp [V'] rw [Set.mem_image] use (⟨T, eq⟩, b) simp exact f_IsGLB_of_V'.1 fcInV' Β· rcases T with ⟨⟨s, r, v⟩, h⟩ let Tc : Ξ€c K₁ Kβ‚‚ V := ⟨⟨(s, r, some 0), by valid⟩, by simp⟩ conv_rhs => rw [←sum_fc_eq_sum (Tc := Tc)] refine' (Finset.sum_le_sum (Ξ» k _ ↦ _)) have fcInV' : fc (Tc, b) k ∈ V' b ⟨(s, r, v), h⟩ k := by dsimp [V'] rw [Set.mem_image] use (⟨⟨(s, r, some 0), by valid⟩, by valid⟩, b) have : v = none := by aesop simp [this, (·≀·)] exact f_IsGLB_of_V'.1 fcInV'
5
38
false
Applied verif.
208
Intmax.v_transactionsInBlocks
lemma v_transactionsInBlocks {s r v v'} {eq₁ eqβ‚‚} {i} (h : Ο€ ≀ Ο€') (hβ‚€ : i < (TransactionsInBlocks Ο€ Bstar).length) (h₁ : (TransactionsInBlocks Ο€ Bstar)[i] = ⟨(s, r, v), eqβ‚βŸ©) (hβ‚‚ : (TransactionsInBlocks Ο€' Bstar)[i]'(by blast with Ο€) = ⟨(s, r, v'), eqβ‚‚βŸ©) : v ≀ v'
FVIntmax
FVIntmax/Lemma4.lean
[ "import FVIntmax.Wheels.Dictionary", "import FVIntmax.Wheels", "import FVIntmax.Balance" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Finite", "module": "Mathlib.Data.Finite.Defs" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" }, { "name": "Finset.sort", "module": "Mathlib.Data.Finset.Sort" }, { "name": "LE", "module": "Init.Prelude" }, { "name": "List.length", "module": "Init.Prelude" }, { "name": "List.map", "module": "Init.Prelude" }, { "name": "Subtype", "module": "Init.Prelude" } ]
[ { "name": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$", "content": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$b, by admit /- proof elided -/\n⟩)" }, { "name": "v'", "content": "def v' (v : Vβ‚Š) (b : S K₁ Kβ‚‚ V) (s : Kbar K₁ Kβ‚‚) : Vβ‚Š :=\n match h : s with\n | .Source => v\n | .key _ => ⟨v βŠ“ b s, by admit /- proof elided -/\n ⟩" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "Kbar", "content": "inductive Kbar (K₁ Kβ‚‚ : Type) where\n | key (k : Key K₁ Kβ‚‚)\n | Source\nderiving DecidableEq" }, { "name": "S", "content": "abbrev S (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { s : S' K₁ Kβ‚‚ V // s.isValid }" }, { "name": "S'", "content": "abbrev S' (K₁ Kβ‚‚ V : Type) := Kbar K₁ Kβ‚‚ β†’ V" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "Block", "content": "inductive Block (K₁ Kβ‚‚ : Type) (C Sigma : Type) (V : Type) [PreWithZero V] where\n \n | deposit (recipient : Kβ‚‚) (amount : Vβ‚Š)\n \n | transfer (aggregator : K₁) (extradata : ExtraDataT) (commitment : C) (senders : List Kβ‚‚) (sigma : Sigma)\n \n | withdrawal (withdrawals : K₁ β†’ Vβ‚Š)" }, { "name": "TransactionsInBlocks", "content": "def TransactionsInBlocks\n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (bs : List (Block K₁ Kβ‚‚ C Sigma V)) : List (Ξ€ K₁ Kβ‚‚ V) :=\n (bs.map (TransactionsInBlock Ο€)).flatten" }, { "name": "TransactionsInBlock", "content": "def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := \n match h : b with\n | .deposit .. => TransactionsInBlock_deposit β†ͺb\n | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb\n | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb" }, { "name": "TransactionsInBlock_withdrawal", "content": "def TransactionsInBlock_withdrawal \n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .withdrawal withdrawals =>\n \n let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·)\n k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/\n ⟩\n | .deposit r v | .transfer .. => by admit /- proof elided -/" }, { "name": "isWithdrawalBlock", "content": "abbrev isWithdrawalBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.withdrawal _)" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "attach", "content": "noncomputable def attach (Ξ± : Type) [Finite Ξ±] : UniquelyIndexed Ξ± :=\n have := Finite.exists_equiv_fin Ξ±\n this.choose_spec.some.toEmbedding" }, { "name": "UniquelyIndexed", "content": "abbrev UniquelyIndexed (Ξ± : Type) [Finite Ξ±] : Type := Ξ± β†ͺ !Ξ±" }, { "name": "UniqueTokenT", "content": "abbrev UniqueTokenT (Ξ± : Type) [Finite Ξ±] : Type := Fin (Finite.exists_equiv_fin Ξ± |>.choose)" }, { "name": "Ξ€", "content": "abbrev Ξ€ (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { Ο„ : Ξ€' K₁ Kβ‚‚ V // Ο„.isValid }" }, { "name": "Ξ€'", "content": "abbrev Ξ€' (K₁ Kβ‚‚ V : Type) [PreWithZero V] := Kbar K₁ Kβ‚‚ Γ— Kbar K₁ Kβ‚‚ Γ— Option Vβ‚Š" }, { "name": "TransactionsInBlock_transfer", "content": "def TransactionsInBlock_transfer \n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .transfer _ _ commitment S _ =>\n \n let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) }\n let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe \n \n let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š :=\n if s βˆ‰ S\n then .some 0\n else \n if h : (commitment, s) ∈ Ο€.keys\n then let (_, t) := Ο€[(commitment, s)]\n t r\n else .none\n sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/\n ⟩\n | .deposit .. | .withdrawal .. => by admit /- proof elided -/" }, { "name": "BalanceProof", "content": "abbrev BalanceProof (K₁ Kβ‚‚ : Type) [Finite K₁] [Finite Kβ‚‚]\n (C Pi V : Type) [PreWithZero V] : Type :=\n Dict (C Γ— Kβ‚‚) ((Pi Γ— ExtraDataT) Γ— TransactionBatch K₁ Kβ‚‚ V) " }, { "name": "TransactionBatch", "content": "abbrev TransactionBatch (K₁ : Type) [Finite K₁]\n (Kβ‚‚ : Type) [Finite Kβ‚‚]\n (V : Type) [PreWithZero V] :=\n Key K₁ Kβ‚‚ β†’ Vβ‚Š" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "lexLe", "content": "def lexLe (a b : Kβ‚‚ Γ— Key K₁ Kβ‚‚) : Prop :=\n a.1 < b.1 ∨ (a.1 = b.1 ∧ a.2 ≀ b.2)" }, { "name": "isTransferBlock", "content": "abbrev isTransferBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.transfer _ _ _ _ _)" }, { "name": "keys", "content": "def keys (m : Dict Ξ± Ο‰) : Set Ξ± := { x | Dict.is_mem m x }" }, { "name": "Dict.is_mem", "content": "def Dict.is_mem (m : Dict Ξ± Ο‰) (x : Ξ±) : Prop := (m x).isSome" }, { "name": "keys", "content": "abbrev keys (ct : CommitT C K Pi) := ct.dict.keys" }, { "name": "CommitT", "content": "structure CommitT (C K Pi : Type) where\n commitment : C\n dict : Dict K Pi" }, { "name": "keysUneq", "content": "abbrev keysUneq (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) : Prop :=\n match k with\n | .inl _ => True\n | .inr kβ‚‚' => kβ‚‚ β‰  kβ‚‚'" }, { "name": "TransactionsInBlock_deposit", "content": "def TransactionsInBlock_deposit\n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/\n ⟩]\n | .withdrawal .. | .transfer .. => by admit /- proof elided -/" }, { "name": "isDepositBlock", "content": "abbrev isDepositBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.deposit _ _) " }, { "name": "infix:50 \" β‰ β‚– \" => Key.keysUneq ", "content": "infix:50 \" β‰ β‚– \" => Key.keysUneq " }, { "name": "prefix:max \"!\" => UniqueTokenT", "content": "prefix:max \"!\" => UniqueTokenT" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "not_and_or", "module": "Mathlib.Logic.Basic" }, { "name": "congr_fun", "module": "Batteries.Logic" } ]
[ { "name": "mem_dict_iff_mem_keys", "content": "lemma mem_dict_iff_mem_keys {dict : Dict Ξ± Ο‰} : k ∈ dict ↔ k ∈ dict.keys" }, { "name": "eq_of_BalanceProof_le", "content": "lemma eq_of_BalanceProof_le (h : Ο€ ≀ Ο€') (h₁ : k ∈ Ο€) (hβ‚‚ : k ∈ Ο€') :\n ((Ο€ k).get h₁).2 = ((Ο€' k).get hβ‚‚).2" }, { "name": "mem_of_BalanceProof_le", "content": "lemma mem_of_BalanceProof_le (h : Ο€ ≀ Ο€') (h₁ : k ∈ Ο€) : k ∈ Ο€'" }, { "name": "notin_of_BalanceProof_le_notin", "content": "lemma notin_of_BalanceProof_le_notin (h : Ο€ ≀ Ο€') (h₁ : k βˆ‰ Ο€') : k βˆ‰ Ο€" }, { "name": "length_TransactionsInBlock_transfer", "content": "lemma length_TransactionsInBlock_transfer\n {b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }} :\n βˆ€ (π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V),\n (TransactionsInBlock_transfer π₁ b).length =\n (TransactionsInBlock_transfer Ο€β‚‚ b).length" }, { "name": "length_transactionsInBlock", "content": "lemma length_transactionsInBlock :\n (TransactionsInBlock π₁ b).length = (TransactionsInBlock Ο€β‚‚ b).length" }, { "name": "map_join_unnecessarily_specific", "content": "lemma map_join_unnecessarily_specific\n {Ξ± Ξ² Ξ³ Ξ΄ Pi : Type}\n [LE Ξ΄]\n [LE Pi]\n {l : List Ξ±}\n {P : (Ξ² Γ— Ξ³ Γ— Ξ΄) β†’ Prop}\n {Ο€ Ο€' : Pi}\n {f : Pi β†’ Ξ± β†’ List (Subtype P)}\n {i : β„•}\n (hβ‚€ : (List.length ∘ f Ο€) = (List.length ∘ f Ο€'))\n (h₁ : βˆ€ (a : Ξ±)\n (i : β„•) (h : i < (f Ο€ a).length),\n (f Ο€ a)[i].1.2.2 ≀ ((f Ο€' a)[i]'(by apply congr_fun at hβ‚€; aesop)).1.2.2)\n (h) :\n ((List.map (f Ο€) l).flatten[i]'h).1.2.2 ≀\n ((List.map (f Ο€') l).flatten[i]'(by aesop)).1.2.2" }, { "name": "map_eq_project_triple", "content": "lemma map_eq_project_triple {Ξ² Ξ³ Ξ΄ : Type}\n {s : Ξ²} {r : Ξ³} {v : Ξ΄}\n {i : β„•}\n {P : (Ξ² Γ— Ξ³ Γ— Ξ΄) β†’ Prop}\n {l : List (Subtype P)}\n {hβ‚€}\n {h : i < l.length} : \n l[i]'h = ⟨(s, r, v), hβ‚€βŸ© β†’ (l[i]'h).1.2.2 = v" } ]
[]
[ { "name": "Intmax.delta_TransactionsInBlock_transfer", "content": "private lemma delta_TransactionsInBlock_transfer\n {b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }}\n (h : Ο€ ≀ Ο€') : \n βˆ€ i : β„•, (hlen : i < (TransactionsInBlock_transfer Ο€ b).length) β†’\n (TransactionsInBlock_transfer Ο€ b)[i]'hlen =\n (TransactionsInBlock_transfer Ο€' b)[i]'(by rwa [length_TransactionsInBlock_transfer _ Ο€]) ∨\n ((TransactionsInBlock_transfer Ο€ b)[i]'hlen).1.2.2.isNone" } ]
import FVIntmax.Balance namespace Intmax open Mathlib noncomputable section Lemma4 section HicSuntDracones section variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [AddCommGroup V] [Lattice V] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} section HelperFunctionsToAppeaseLean open Mathlib open Lean.Elab.Tactic in section variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} end end HelperFunctionsToAppeaseLean end section variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs Bstar : List (Block K₁ Kβ‚‚ C Sigma V)}
lemma v_transactionsInBlocks {s r v v'} {eq₁ eqβ‚‚} {i} (h : Ο€ ≀ Ο€') (hβ‚€ : i < (TransactionsInBlocks Ο€ Bstar).length) (h₁ : (TransactionsInBlocks Ο€ Bstar)[i] = ⟨(s, r, v), eqβ‚βŸ©) (hβ‚‚ : (TransactionsInBlocks Ο€' Bstar)[i]'(by blast with Ο€) = ⟨(s, r, v'), eqβ‚‚βŸ©) : v ≀ v' :=
:= by unfold TransactionsInBlocks at h₁ hβ‚‚ apply List.map_eq_project_triple at h₁ apply List.map_eq_project_triple at hβ‚‚ rw [←h₁, ←hβ‚‚] apply List.map_join_unnecessarily_specific (by ext x; simp; rw [length_transactionsInBlock]) intros b i h₃ unfold TransactionsInBlock match h' : b with | Block.transfer .. => rcases delta_TransactionsInBlock_transfer (b := ⟨b, by aesop⟩) h i (by aesop) <;> [aesop; (simp [(·≀·)]; aesop)] | Block.deposit .. | Block.withdrawal .. => simp
7
57
false
Applied verif.
209
Intmax.lemma3
lemma lemma3 : Bal Ο€ bs .Source ≀ 0
FVIntmax
FVIntmax/Lemma3.lean
[ "import FVIntmax.Balance" ]
[ { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "IsGLB", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "And", "module": "Init.Prelude" }, { "name": "IsGreatest", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "lowerBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "upperBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "InfSet", "module": "Mathlib.Order.SetNotation" }, { "name": "iInf", "module": "Mathlib.Order.SetNotation" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Finite", "module": "Mathlib.Data.Finite.Defs" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" }, { "name": "Finset.univ", "module": "Mathlib.Data.Fintype.Defs" } ]
[ { "name": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$", "content": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$b, by admit /- proof elided -/\n⟩)" }, { "name": "fStar", "content": "def fStar (Ts : List (Ξ€ K₁ Kβ‚‚ V)) (sβ‚€ : S K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n Ts.foldl f sβ‚€" }, { "name": "f", "content": "def f (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨\n Ξ» k ↦\n have : InfSet V := infV b T k\n β¨… x : boundedBelow b T, fc x.1 k,\n by admit /- proof elided -/\n ⟩" }, { "name": "infV", "content": "def infV (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) :\n InfSet V where\n sInf := Ξ» s ↦ if s = V' b T k\n then (exists_inf b T).1 k\n else 0" }, { "name": "exists_inf", "content": "def exists_inf (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : { s : S K₁ Kβ‚‚ V // βˆ€ k, IsGLB (V' b T k) (s k) } :=\n ⟨\n f' b T,\n Ξ» k ↦\n have f'_codomain : (f' b T) k ∈ V' b T k := by admit /- proof elided -/\n ⟩" }, { "name": "fc", "content": "def fc (Ο„cXb : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨λ k : Kbar K₁ Kβ‚‚ ↦\n match Ο„cXb with\n | ⟨⟨⟨⟨s, r, v⟩, _⟩, hΟ„βŸ©, b⟩ =>\n let v' := v' (v.get hΟ„) b s\n b k + (e r - e s) k β€’ v',\n by admit /- proof elided -/\n ⟩" }, { "name": "e", "content": "def e (i : Kbar K₁ Kβ‚‚) : Kbar K₁ Kβ‚‚ β†’ β„€ := Ξ» j ↦ if i = j then 1 else 0" }, { "name": "Kbar", "content": "inductive Kbar (K₁ Kβ‚‚ : Type) where\n | key (k : Key K₁ Kβ‚‚)\n | Source\nderiving DecidableEq" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "S", "content": "abbrev S (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { s : S' K₁ Kβ‚‚ V // s.isValid }" }, { "name": "S'", "content": "abbrev S' (K₁ Kβ‚‚ V : Type) := Kbar K₁ Kβ‚‚ β†’ V" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "Ξ€c", "content": "abbrev Ξ€c (K₁ Kβ‚‚ V : Type) [PreWithZero V] : Type := { Ο„ : Ξ€ K₁ Kβ‚‚ V // Ο„.isComplete }" }, { "name": "Ξ€", "content": "abbrev Ξ€ (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { Ο„ : Ξ€' K₁ Kβ‚‚ V // Ο„.isValid }" }, { "name": "Ξ€'", "content": "abbrev Ξ€' (K₁ Kβ‚‚ V : Type) [PreWithZero V] := Kbar K₁ Kβ‚‚ Γ— Kbar K₁ Kβ‚‚ Γ— Option Vβ‚Š" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "boundedBelow", "content": "abbrev boundedBelow (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) :=\n { a : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V | (T, b) ≀ (↑a.1, a.2) }" }, { "name": "f'", "content": "def f' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := \n ⟨\n Ξ» k ↦\n match h : T with\n | ⟨(_, _, .some _), hT⟩ => fc (⟨T, by admit /- proof elided -/\n ⟩, b) k\n | ⟨(s, _, .none), _⟩ => if k = s then 0 else b k,\n by admit /- proof elided -/\n ⟩" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "V'", "content": "def V' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) : Set V :=\n { v : V | v ∈ (fc Β· k) '' boundedBelow b T }" }, { "name": "isComplete", "content": "def isComplete (Ο„ : Ξ€ K₁ Kβ‚‚ V) :=\n match Ο„ with | ⟨(_, _, v), _⟩ => v.isSome" }, { "name": "TransactionsInBlocks", "content": "def TransactionsInBlocks\n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (bs : List (Block K₁ Kβ‚‚ C Sigma V)) : List (Ξ€ K₁ Kβ‚‚ V) :=\n (bs.map (TransactionsInBlock Ο€)).flatten" }, { "name": "TransactionsInBlock", "content": "def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := \n match h : b with\n | .deposit .. => TransactionsInBlock_deposit β†ͺb\n | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb\n | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb" }, { "name": "TransactionsInBlock_withdrawal", "content": "def TransactionsInBlock_withdrawal \n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .withdrawal withdrawals =>\n \n let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·)\n k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/\n ⟩\n | .deposit r v | .transfer .. => by admit /- proof elided -/" }, { "name": "Block", "content": "inductive Block (K₁ Kβ‚‚ : Type) (C Sigma : Type) (V : Type) [PreWithZero V] where\n \n | deposit (recipient : Kβ‚‚) (amount : Vβ‚Š)\n \n | transfer (aggregator : K₁) (extradata : ExtraDataT) (commitment : C) (senders : List Kβ‚‚) (sigma : Sigma)\n \n | withdrawal (withdrawals : K₁ β†’ Vβ‚Š)" }, { "name": "isWithdrawalBlock", "content": "abbrev isWithdrawalBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.withdrawal _)" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "attach", "content": "noncomputable def attach (Ξ± : Type) [Finite Ξ±] : UniquelyIndexed Ξ± :=\n have := Finite.exists_equiv_fin Ξ±\n this.choose_spec.some.toEmbedding" }, { "name": "UniquelyIndexed", "content": "abbrev UniquelyIndexed (Ξ± : Type) [Finite Ξ±] : Type := Ξ± β†ͺ !Ξ±" }, { "name": "UniqueTokenT", "content": "abbrev UniqueTokenT (Ξ± : Type) [Finite Ξ±] : Type := Fin (Finite.exists_equiv_fin Ξ± |>.choose)" }, { "name": "TransactionsInBlock_transfer", "content": "def TransactionsInBlock_transfer \n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .transfer _ _ commitment S _ =>\n \n let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) }\n let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe \n \n let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š :=\n if s βˆ‰ S\n then .some 0\n else \n if h : (commitment, s) ∈ Ο€.keys\n then let (_, t) := Ο€[(commitment, s)]\n t r\n else .none\n sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/\n ⟩\n | .deposit .. | .withdrawal .. => by admit /- proof elided -/" }, { "name": "BalanceProof", "content": "abbrev BalanceProof (K₁ Kβ‚‚ : Type) [Finite K₁] [Finite Kβ‚‚]\n (C Pi V : Type) [PreWithZero V] : Type :=\n Dict (C Γ— Kβ‚‚) ((Pi Γ— ExtraDataT) Γ— TransactionBatch K₁ Kβ‚‚ V) " }, { "name": "TransactionBatch", "content": "abbrev TransactionBatch (K₁ : Type) [Finite K₁]\n (Kβ‚‚ : Type) [Finite Kβ‚‚]\n (V : Type) [PreWithZero V] :=\n Key K₁ Kβ‚‚ β†’ Vβ‚Š" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "lexLe", "content": "def lexLe (a b : Kβ‚‚ Γ— Key K₁ Kβ‚‚) : Prop :=\n a.1 < b.1 ∨ (a.1 = b.1 ∧ a.2 ≀ b.2)" }, { "name": "isTransferBlock", "content": "abbrev isTransferBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.transfer _ _ _ _ _)" }, { "name": "keys", "content": "def keys (m : Dict Ξ± Ο‰) : Set Ξ± := { x | Dict.is_mem m x }" }, { "name": "Dict.is_mem", "content": "def Dict.is_mem (m : Dict Ξ± Ο‰) (x : Ξ±) : Prop := (m x).isSome" }, { "name": "keys", "content": "abbrev keys (ct : CommitT C K Pi) := ct.dict.keys" }, { "name": "CommitT", "content": "structure CommitT (C K Pi : Type) where\n commitment : C\n dict : Dict K Pi" }, { "name": "keysUneq", "content": "abbrev keysUneq (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) : Prop :=\n match k with\n | .inl _ => True\n | .inr kβ‚‚' => kβ‚‚ β‰  kβ‚‚'" }, { "name": "TransactionsInBlock_deposit", "content": "def TransactionsInBlock_deposit\n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/\n ⟩]\n | .withdrawal .. | .transfer .. => by admit /- proof elided -/" }, { "name": "isDepositBlock", "content": "abbrev isDepositBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.deposit _ _) " }, { "name": "Bal", "content": "def Bal (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (bs : List (Block K₁ Kβ‚‚ C Sigma V)) : S K₁ Kβ‚‚ V :=\n fStar (TransactionsInBlocks Ο€ bs) (.initial K₁ Kβ‚‚ V)" }, { "name": "initial", "content": "def initial : Scontract K₁ Kβ‚‚ V C Sigma := []" }, { "name": "Scontract", "content": "abbrev Scontract (K₁ Kβ‚‚ V : Type) [PreWithZero V] (C Sigma : Type) :=\n List (Block K₁ Kβ‚‚ C Sigma V)" }, { "name": "initial", "content": "def initial (K₁ Kβ‚‚ V : Type) [PreWithZero V] : S K₁ Kβ‚‚ V :=\n ⟨S'.initial K₁ Kβ‚‚ V, S'.isValid_initial⟩" }, { "name": "infix:50 \" β‰ β‚– \" => Key.keysUneq ", "content": "infix:50 \" β‰ β‚– \" => Key.keysUneq " }, { "name": "prefix:max \"!\" => UniqueTokenT", "content": "prefix:max \"!\" => UniqueTokenT" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "Finset.sum_add_distrib", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Basic" }, { "name": "Finset.sum_smul", "module": "Mathlib.Algebra.Module.BigOperators" }, { "name": "Finset.sum_le_sum", "module": "Mathlib.Algebra.Order.BigOperators.Group.Finset" }, { "name": "Set.mem_image", "module": "Mathlib.Data.Set.Operations" }, { "name": "le_trans", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Finset.sum_nonneg", "module": "Mathlib.Algebra.Order.BigOperators.Group.Finset" }, { "name": "Finset.sum_singleton", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Basic" }, { "name": "sub_nonpos", "module": "Mathlib.Algebra.Order.Group.Unbundled.Basic" } ]
[ { "name": "f_IsGLB_of_V'", "content": "lemma f_IsGLB_of_V' {b : S K₁ Kβ‚‚ V} {T : Ξ€ K₁ Kβ‚‚ V} {k : Kbar K₁ Kβ‚‚} :\n IsGLB (V' b T k) (f b T k)" } ]
[]
[ { "name": "Intmax.sum_fc_eq_sum", "content": "@[simp]\nlemma sum_fc_eq_sum : βˆ‘ (k : Kbar K₁ Kβ‚‚), fc (Tc, b) k = βˆ‘ (k : Kbar K₁ Kβ‚‚), b k" }, { "name": "Intmax.sum_f_le_sum", "content": "lemma sum_f_le_sum : βˆ‘ (k : Kbar K₁ Kβ‚‚), f b T k ≀ βˆ‘ (k : Kbar K₁ Kβ‚‚), b k" }, { "name": "Intmax.sum_fStar_le_zero_aux", "content": "private lemma sum_fStar_le_zero_aux (h : βˆ‘ (k : Kbar K₁ Kβ‚‚), b k ≀ 0) :\n βˆ‘ (k : Kbar K₁ Kβ‚‚), fStar Tstar b k ≀ 0" } ]
import FVIntmax.Balance namespace Intmax section Lemma3 variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] variable {Tc : Ξ€c K₁ Kβ‚‚ V} {T : Ξ€ K₁ Kβ‚‚ V} {b : S K₁ Kβ‚‚ V} {Tstar : List (Ξ€ K₁ Kβ‚‚ V)} variable [LinearOrder K₁] [LinearOrder Kβ‚‚] {Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)}
lemma lemma3 : Bal Ο€ bs .Source ≀ 0 :=
:= by dsimp [Bal] generalize eq : TransactionsInBlocks Ο€ _ = blocks generalize eq₁ : S.initial K₁ Kβ‚‚ V = sβ‚€ generalize eqβ‚‚ : fStar blocks sβ‚€ = f have : βˆ‘ x ∈ {Kbar.Source}, f x = βˆ‘ x : Kbar K₁ Kβ‚‚, f x - βˆ‘ x ∈ Finset.univ \ {Kbar.Source}, f x := by simp rw [←Finset.sum_singleton (a := Kbar.Source) (f := f), this, sub_nonpos] have := sum_fStar_le_zero_aux (Tstar := blocks) (b := sβ‚€) have eq₃ : βˆ‘ x : Kbar K₁ Kβ‚‚, f x ≀ 0 := by aesop have eqβ‚„ : 0 ≀ βˆ‘ x ∈ Finset.univ \ {Kbar.Source}, f x := Finset.sum_nonneg Ξ» i ↦ by rcases i <;> aesop exact le_trans eq₃ eqβ‚„
9
75
false
Applied verif.
210
Intmax.proposition4
lemma proposition4 [Setoid' X] {x y : Option X} : (βˆƒ join : Option X, IsLUB {x, y, .none} join) ↔ (x β‰  .none ∧ y β‰  .none β†’ x β‰… y)
FVIntmax
FVIntmax/Propositions.lean
[ "import Mathlib.Order.Bounds.Basic", "import FVIntmax.Wheels.Dictionary", "import Aesop", "import Mathlib.Order.Bounds.Defs", "import Mathlib.Order.Defs" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "IsLUB", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Iff", "module": "Init.Core" }, { "name": "IsLeast", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "lowerBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "upperBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Set.Ici", "module": "Mathlib.Order.Interval.Set.Defs" } ]
[ { "name": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b", "content": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b" } ]
[ { "name": "le_trans", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "mem_upperBounds", "module": "Mathlib.Order.Bounds.Basic" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Intmax.iso", "content": "def iso {X : Type} [Preorder X] (a b : X) := a ≀ b ∧ b ≀ a" }, { "name": "Intmax.IsEquivRel", "content": "def IsEquivRel {X : Type} [Preorder X] := βˆ€ a b : X, a ≀ b ↔ a β‰… b" }, { "name": "Intmax.Setoid'", "content": "class Setoid' (X : Type) extends Preorder X where\n isEquiv : IsEquivRel (X := X)" } ]
[ { "name": "Intmax.iso_rfl", "content": "@[simp, refl]\nlemma iso_rfl : a β‰… a" }, { "name": "Intmax.iso_trans", "content": "@[trans]\nlemma iso_trans : (a β‰… b) β†’ (b β‰… c) β†’ a β‰… c" }, { "name": "Intmax.proposition2", "content": "lemma proposition2 [Setoid' X] {x y : X} :\n (βˆƒ join : X, IsLUB {x, y} join) ↔ x β‰… y" }, { "name": "Intmax.proposition2'", "content": "lemma proposition2' [Setoid' X] {join x y : X} (h : IsLUB {x, y} join) :\n (x β‰… join) ∧ y β‰… join" }, { "name": "Intmax.proposition3'", "content": "lemma proposition3' : \n (βˆƒ join : X, IsLUB {x, y} join) ↔ (βˆƒ join : Option X, IsLUB {.some x, .some y, .none} join)" } ]
import Mathlib.Order.Bounds.Basic import Mathlib.Order.Bounds.Defs import Mathlib.Order.Defs import Aesop import FVIntmax.Wheels.Dictionary namespace Intmax def iso {X : Type} [Preorder X] (a b : X) := a ≀ b ∧ b ≀ a notation:51 (priority := high) a:52 " β‰… " b:52 => iso a b section iso variable {X : Type} [Preorder X] {a b c : X} end iso def IsEquivRel {X : Type} [Preorder X] := βˆ€ a b : X, a ≀ b ↔ a β‰… b class Setoid' (X : Type) extends Preorder X where isEquiv : IsEquivRel (X := X) section Automation variable {Ξ± : Type} [Preorder Ξ±] {x y : Ξ±} end Automation section Propositions variable {X Y : Type} section proposition3 variable [Preorder X] {x? y? join? join'? : Option X} {x y join join' : X} end proposition3 section Automation variable {X : Type} [Setoid' X] {x y : X} {x? y? : Option X} end Automation
lemma proposition4 [Setoid' X] {x y : Option X} : (βˆƒ join : Option X, IsLUB {x, y, .none} join) ↔ (x β‰  .none ∧ y β‰  .none β†’ x β‰… y) :=
:= by refine' Iff.intro (Ξ» h ⟨h₁, hβ‚‚βŸ© ↦ _) (Ξ» h ↦ _) Β· rcases x with _ | x <;> rcases y with _ | y <;> [rfl; simp at h₁; simp at hβ‚‚; skip] simp rw [←proposition3'] at h rcases h with ⟨join, h⟩ obtain ⟨h₁, hβ‚‚βŸ© := proposition2' h exact iso_trans h₁ hβ‚‚.symm Β· rcases x with _ | x <;> rcases y with _ | y Β· use .none; simp Β· use .some y; simp Β· use .some x; simp Β· simp at h simp_rw [←proposition3'] exact proposition2.2 h
3
19
false
Applied verif.
211
Intmax.sender_transactionsInBlock
lemma sender_transactionsInBlock : (TransactionsInBlock π₁ b).map (Ξ» s ↦ s.1.1) = (TransactionsInBlock Ο€β‚‚ b).map (Ξ» s ↦ s.1.1)
FVIntmax
FVIntmax/Balance.lean
[ "import FVIntmax.BalanceProof", "import FVIntmax.Wheels", "import FVIntmax.Propositions", "import Mathlib", "import FVIntmax.Key", "import FVIntmax.Block", "import Mathlib.Algebra.Group.Int", "import FVIntmax.Wheels.Dictionary", "import FVIntmax.State", "import FVIntmax.Transaction" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Finite", "module": "Mathlib.Data.Finite.Defs" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" }, { "name": "Sum", "module": "Init.Core" } ]
[ { "name": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$", "content": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$b, by admit /- proof elided -/\n⟩)" }, { "name": "Block", "content": "inductive Block (K₁ Kβ‚‚ : Type) (C Sigma : Type) (V : Type) [PreWithZero V] where\n \n | deposit (recipient : Kβ‚‚) (amount : Vβ‚Š)\n \n | transfer (aggregator : K₁) (extradata : ExtraDataT) (commitment : C) (senders : List Kβ‚‚) (sigma : Sigma)\n \n | withdrawal (withdrawals : K₁ β†’ Vβ‚Š)" }, { "name": "isWithdrawalBlock", "content": "abbrev isWithdrawalBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.withdrawal _)" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "attach", "content": "noncomputable def attach (Ξ± : Type) [Finite Ξ±] : UniquelyIndexed Ξ± :=\n have := Finite.exists_equiv_fin Ξ±\n this.choose_spec.some.toEmbedding" }, { "name": "UniquelyIndexed", "content": "abbrev UniquelyIndexed (Ξ± : Type) [Finite Ξ±] : Type := Ξ± β†ͺ !Ξ±" }, { "name": "UniqueTokenT", "content": "abbrev UniqueTokenT (Ξ± : Type) [Finite Ξ±] : Type := Fin (Finite.exists_equiv_fin Ξ± |>.choose)" }, { "name": "Ξ€", "content": "abbrev Ξ€ (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { Ο„ : Ξ€' K₁ Kβ‚‚ V // Ο„.isValid }" }, { "name": "Ξ€'", "content": "abbrev Ξ€' (K₁ Kβ‚‚ V : Type) [PreWithZero V] := Kbar K₁ Kβ‚‚ Γ— Kbar K₁ Kβ‚‚ Γ— Option Vβ‚Š" }, { "name": "Kbar", "content": "inductive Kbar (K₁ Kβ‚‚ : Type) where\n | key (k : Key K₁ Kβ‚‚)\n | Source\nderiving DecidableEq" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "BalanceProof", "content": "abbrev BalanceProof (K₁ Kβ‚‚ : Type) [Finite K₁] [Finite Kβ‚‚]\n (C Pi V : Type) [PreWithZero V] : Type :=\n Dict (C Γ— Kβ‚‚) ((Pi Γ— ExtraDataT) Γ— TransactionBatch K₁ Kβ‚‚ V) " }, { "name": "TransactionBatch", "content": "abbrev TransactionBatch (K₁ : Type) [Finite K₁]\n (Kβ‚‚ : Type) [Finite Kβ‚‚]\n (V : Type) [PreWithZero V] :=\n Key K₁ Kβ‚‚ β†’ Vβ‚Š" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "lexLe", "content": "def lexLe (a b : Kβ‚‚ Γ— Key K₁ Kβ‚‚) : Prop :=\n a.1 < b.1 ∨ (a.1 = b.1 ∧ a.2 ≀ b.2)" }, { "name": "isTransferBlock", "content": "abbrev isTransferBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.transfer _ _ _ _ _)" }, { "name": "keys", "content": "def keys (m : Dict Ξ± Ο‰) : Set Ξ± := { x | Dict.is_mem m x }" }, { "name": "Dict.is_mem", "content": "def Dict.is_mem (m : Dict Ξ± Ο‰) (x : Ξ±) : Prop := (m x).isSome" }, { "name": "keys", "content": "abbrev keys (ct : CommitT C K Pi) := ct.dict.keys" }, { "name": "CommitT", "content": "structure CommitT (C K Pi : Type) where\n commitment : C\n dict : Dict K Pi" }, { "name": "keysUneq", "content": "abbrev keysUneq (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) : Prop :=\n match k with\n | .inl _ => True\n | .inr kβ‚‚' => kβ‚‚ β‰  kβ‚‚'" }, { "name": "isDepositBlock", "content": "abbrev isDepositBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.deposit _ _) " }, { "name": "infix:50 \" β‰ β‚– \" => Key.keysUneq ", "content": "infix:50 \" β‰ β‚– \" => Key.keysUneq " }, { "name": "prefix:max \"!\" => UniqueTokenT", "content": "prefix:max \"!\" => UniqueTokenT" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "Finset.length_sort", "module": "Mathlib.Data.Finset.Sort" }, { "name": "List.length_attach", "module": "Init.Data.List.Attach" }, { "name": "List.length_map", "module": "Init.Data.List.Lemmas" }, { "name": "exists_and_left", "module": "Init.PropLemmas" }, { "name": "exists_prop", "module": "Init.PropLemmas" }, { "name": "ite_not", "module": "Init.PropLemmas" }, { "name": "true_and", "module": "Init.SimpLemmas" }, { "name": "List.ext_get", "module": "Init.Data.List.Lemmas" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Intmax.TransactionsInBlock_deposit", "content": "def TransactionsInBlock_deposit\n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/\n ⟩]\n | .withdrawal .. | .transfer .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock_transfer", "content": "def TransactionsInBlock_transfer \n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .transfer _ _ commitment S _ =>\n \n let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) }\n let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe \n \n let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š :=\n if s βˆ‰ S\n then .some 0\n else \n if h : (commitment, s) ∈ Ο€.keys\n then let (_, t) := Ο€[(commitment, s)]\n t r\n else .none\n sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/\n ⟩\n | .deposit .. | .withdrawal .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock_withdrawal", "content": "def TransactionsInBlock_withdrawal \n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .withdrawal withdrawals =>\n \n let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·)\n k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/\n ⟩\n | .deposit r v | .transfer .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock", "content": "def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := \n match h : b with\n | .deposit .. => TransactionsInBlock_deposit β†ͺb\n | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb\n | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb" } ]
[ { "name": "Intmax.length_TransactionsInBlock_transfer", "content": "lemma length_TransactionsInBlock_transfer\n {b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }} :\n βˆ€ (π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V),\n (TransactionsInBlock_transfer π₁ b).length =\n (TransactionsInBlock_transfer Ο€β‚‚ b).length" }, { "name": "Intmax.length_transactionsInBlock", "content": "lemma length_transactionsInBlock :\n (TransactionsInBlock π₁ b).length = (TransactionsInBlock Ο€β‚‚ b).length" } ]
import Mathlib import Mathlib.Algebra.Group.Int import FVIntmax.BalanceProof import FVIntmax.Block import FVIntmax.Key import FVIntmax.Propositions import FVIntmax.State import FVIntmax.Transaction import FVIntmax.Wheels import FVIntmax.Wheels.Dictionary namespace Intmax noncomputable section open Classical section Balance variable {Pi K₁ Kβ‚‚ V C Sigma : Type} section Extraction section Deposit variable [PreWithZero V] def TransactionsInBlock_deposit (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/ ⟩] | .withdrawal .. | .transfer .. => by admit /- proof elided -/ end Deposit section Transfer variable [Finite K₁] [Finite Kβ‚‚] [LinearOrder K₁] [LinearOrder Kβ‚‚] [PreWithZero V] def TransactionsInBlock_transfer (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .transfer _ _ commitment S _ => let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) } let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š := if s βˆ‰ S then .some 0 else if h : (commitment, s) ∈ Ο€.keys then let (_, t) := Ο€[(commitment, s)] t r else .none sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/ ⟩ | .deposit .. | .withdrawal .. => by admit /- proof elided -/ end Transfer section Withdrawal variable [LinearOrder K₁] [Finite K₁] [PreWithZero V] def TransactionsInBlock_withdrawal (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .withdrawal withdrawals => let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·) k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/ ⟩ | .deposit r v | .transfer .. => by admit /- proof elided -/ end Withdrawal variable [Finite K₁] [LinearOrder K₁] [Finite Kβ‚‚] [LinearOrder Kβ‚‚] [PreWithZero V] {b : Block K₁ Kβ‚‚ C Sigma V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} {π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V} def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b with | .deposit .. => TransactionsInBlock_deposit β†ͺb | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb
lemma sender_transactionsInBlock : (TransactionsInBlock π₁ b).map (Ξ» s ↦ s.1.1) = (TransactionsInBlock Ο€β‚‚ b).map (Ξ» s ↦ s.1.1) :=
:= by apply List.ext_get (by simp; rw [length_transactionsInBlock]) intros n h₁ hβ‚‚ simp; unfold TransactionsInBlock match b with | Block.deposit .. => simp [TransactionsInBlock_deposit] | Block.transfer .. => simp [TransactionsInBlock_transfer] | Block.withdrawal .. => simp [TransactionsInBlock_withdrawal]
5
48
false
Applied verif.
212
Intmax.receiver_transactionsInBlock
lemma receiver_transactionsInBlock : (TransactionsInBlock π₁ b).map (Ξ» s ↦ s.1.2.1) = (TransactionsInBlock Ο€β‚‚ b).map (Ξ» s ↦ s.1.2.1)
FVIntmax
FVIntmax/Balance.lean
[ "import FVIntmax.BalanceProof", "import FVIntmax.Wheels", "import FVIntmax.Propositions", "import Mathlib", "import FVIntmax.Key", "import FVIntmax.Block", "import Mathlib.Algebra.Group.Int", "import FVIntmax.Wheels.Dictionary", "import FVIntmax.State", "import FVIntmax.Transaction" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Finite", "module": "Mathlib.Data.Finite.Defs" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" }, { "name": "Sum", "module": "Init.Core" } ]
[ { "name": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$", "content": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$b, by admit /- proof elided -/\n⟩)" }, { "name": "Block", "content": "inductive Block (K₁ Kβ‚‚ : Type) (C Sigma : Type) (V : Type) [PreWithZero V] where\n \n | deposit (recipient : Kβ‚‚) (amount : Vβ‚Š)\n \n | transfer (aggregator : K₁) (extradata : ExtraDataT) (commitment : C) (senders : List Kβ‚‚) (sigma : Sigma)\n \n | withdrawal (withdrawals : K₁ β†’ Vβ‚Š)" }, { "name": "isWithdrawalBlock", "content": "abbrev isWithdrawalBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.withdrawal _)" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "attach", "content": "noncomputable def attach (Ξ± : Type) [Finite Ξ±] : UniquelyIndexed Ξ± :=\n have := Finite.exists_equiv_fin Ξ±\n this.choose_spec.some.toEmbedding" }, { "name": "UniquelyIndexed", "content": "abbrev UniquelyIndexed (Ξ± : Type) [Finite Ξ±] : Type := Ξ± β†ͺ !Ξ±" }, { "name": "UniqueTokenT", "content": "abbrev UniqueTokenT (Ξ± : Type) [Finite Ξ±] : Type := Fin (Finite.exists_equiv_fin Ξ± |>.choose)" }, { "name": "Ξ€", "content": "abbrev Ξ€ (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { Ο„ : Ξ€' K₁ Kβ‚‚ V // Ο„.isValid }" }, { "name": "Ξ€'", "content": "abbrev Ξ€' (K₁ Kβ‚‚ V : Type) [PreWithZero V] := Kbar K₁ Kβ‚‚ Γ— Kbar K₁ Kβ‚‚ Γ— Option Vβ‚Š" }, { "name": "Kbar", "content": "inductive Kbar (K₁ Kβ‚‚ : Type) where\n | key (k : Key K₁ Kβ‚‚)\n | Source\nderiving DecidableEq" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "BalanceProof", "content": "abbrev BalanceProof (K₁ Kβ‚‚ : Type) [Finite K₁] [Finite Kβ‚‚]\n (C Pi V : Type) [PreWithZero V] : Type :=\n Dict (C Γ— Kβ‚‚) ((Pi Γ— ExtraDataT) Γ— TransactionBatch K₁ Kβ‚‚ V) " }, { "name": "TransactionBatch", "content": "abbrev TransactionBatch (K₁ : Type) [Finite K₁]\n (Kβ‚‚ : Type) [Finite Kβ‚‚]\n (V : Type) [PreWithZero V] :=\n Key K₁ Kβ‚‚ β†’ Vβ‚Š" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "lexLe", "content": "def lexLe (a b : Kβ‚‚ Γ— Key K₁ Kβ‚‚) : Prop :=\n a.1 < b.1 ∨ (a.1 = b.1 ∧ a.2 ≀ b.2)" }, { "name": "isTransferBlock", "content": "abbrev isTransferBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.transfer _ _ _ _ _)" }, { "name": "keys", "content": "def keys (m : Dict Ξ± Ο‰) : Set Ξ± := { x | Dict.is_mem m x }" }, { "name": "Dict.is_mem", "content": "def Dict.is_mem (m : Dict Ξ± Ο‰) (x : Ξ±) : Prop := (m x).isSome" }, { "name": "keys", "content": "abbrev keys (ct : CommitT C K Pi) := ct.dict.keys" }, { "name": "CommitT", "content": "structure CommitT (C K Pi : Type) where\n commitment : C\n dict : Dict K Pi" }, { "name": "keysUneq", "content": "abbrev keysUneq (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) : Prop :=\n match k with\n | .inl _ => True\n | .inr kβ‚‚' => kβ‚‚ β‰  kβ‚‚'" }, { "name": "isDepositBlock", "content": "abbrev isDepositBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.deposit _ _) " }, { "name": "infix:50 \" β‰ β‚– \" => Key.keysUneq ", "content": "infix:50 \" β‰ β‚– \" => Key.keysUneq " }, { "name": "prefix:max \"!\" => UniqueTokenT", "content": "prefix:max \"!\" => UniqueTokenT" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "Finset.length_sort", "module": "Mathlib.Data.Finset.Sort" }, { "name": "List.length_attach", "module": "Init.Data.List.Attach" }, { "name": "List.length_map", "module": "Init.Data.List.Lemmas" }, { "name": "exists_and_left", "module": "Init.PropLemmas" }, { "name": "exists_prop", "module": "Init.PropLemmas" }, { "name": "ite_not", "module": "Init.PropLemmas" }, { "name": "true_and", "module": "Init.SimpLemmas" }, { "name": "List.ext_get", "module": "Init.Data.List.Lemmas" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Intmax.TransactionsInBlock_deposit", "content": "def TransactionsInBlock_deposit\n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/\n ⟩]\n | .withdrawal .. | .transfer .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock_transfer", "content": "def TransactionsInBlock_transfer \n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .transfer _ _ commitment S _ =>\n \n let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) }\n let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe \n \n let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š :=\n if s βˆ‰ S\n then .some 0\n else \n if h : (commitment, s) ∈ Ο€.keys\n then let (_, t) := Ο€[(commitment, s)]\n t r\n else .none\n sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/\n ⟩\n | .deposit .. | .withdrawal .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock_withdrawal", "content": "def TransactionsInBlock_withdrawal \n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .withdrawal withdrawals =>\n \n let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·)\n k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/\n ⟩\n | .deposit r v | .transfer .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock", "content": "def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := \n match h : b with\n | .deposit .. => TransactionsInBlock_deposit β†ͺb\n | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb\n | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb" } ]
[ { "name": "Intmax.length_TransactionsInBlock_transfer", "content": "lemma length_TransactionsInBlock_transfer\n {b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }} :\n βˆ€ (π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V),\n (TransactionsInBlock_transfer π₁ b).length =\n (TransactionsInBlock_transfer Ο€β‚‚ b).length" }, { "name": "Intmax.length_transactionsInBlock", "content": "lemma length_transactionsInBlock :\n (TransactionsInBlock π₁ b).length = (TransactionsInBlock Ο€β‚‚ b).length" } ]
import Mathlib import Mathlib.Algebra.Group.Int import FVIntmax.BalanceProof import FVIntmax.Block import FVIntmax.Key import FVIntmax.Propositions import FVIntmax.State import FVIntmax.Transaction import FVIntmax.Wheels import FVIntmax.Wheels.Dictionary namespace Intmax noncomputable section open Classical section Balance variable {Pi K₁ Kβ‚‚ V C Sigma : Type} section Extraction section Deposit variable [PreWithZero V] def TransactionsInBlock_deposit (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/ ⟩] | .withdrawal .. | .transfer .. => by admit /- proof elided -/ end Deposit section Transfer variable [Finite K₁] [Finite Kβ‚‚] [LinearOrder K₁] [LinearOrder Kβ‚‚] [PreWithZero V] def TransactionsInBlock_transfer (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .transfer _ _ commitment S _ => let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) } let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š := if s βˆ‰ S then .some 0 else if h : (commitment, s) ∈ Ο€.keys then let (_, t) := Ο€[(commitment, s)] t r else .none sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/ ⟩ | .deposit .. | .withdrawal .. => by admit /- proof elided -/ end Transfer section Withdrawal variable [LinearOrder K₁] [Finite K₁] [PreWithZero V] def TransactionsInBlock_withdrawal (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .withdrawal withdrawals => let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·) k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/ ⟩ | .deposit r v | .transfer .. => by admit /- proof elided -/ end Withdrawal variable [Finite K₁] [LinearOrder K₁] [Finite Kβ‚‚] [LinearOrder Kβ‚‚] [PreWithZero V] {b : Block K₁ Kβ‚‚ C Sigma V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} {π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V} def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b with | .deposit .. => TransactionsInBlock_deposit β†ͺb | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb
lemma receiver_transactionsInBlock : (TransactionsInBlock π₁ b).map (Ξ» s ↦ s.1.2.1) = (TransactionsInBlock Ο€β‚‚ b).map (Ξ» s ↦ s.1.2.1) :=
:= by apply List.ext_get (by simp; rw [length_transactionsInBlock]) intros n h₁ hβ‚‚ simp; unfold TransactionsInBlock match b with | Block.deposit .. => simp [TransactionsInBlock_deposit] | Block.transfer .. => simp [TransactionsInBlock_transfer] | Block.withdrawal .. => simp [TransactionsInBlock_withdrawal]
5
48
false
Applied verif.
213
Intmax.f_withdrawal_block_source
lemma f_withdrawal_block_source (h : b.isWithdrawalBlock) : ((TransactionsInBlock Ο€ b).foldl f Οƒ) .Source = Οƒ .Source + βˆ‘ k : K₁, (b.getWithdrawal h k).1 βŠ“ Οƒ k
FVIntmax
FVIntmax/Balance.lean
[ "import FVIntmax.BalanceProof", "import FVIntmax.Wheels", "import FVIntmax.Propositions", "import Mathlib", "import FVIntmax.Key", "import FVIntmax.Block", "import Mathlib.Algebra.Group.Int", "import FVIntmax.Wheels.Dictionary", "import FVIntmax.State", "import FVIntmax.Transaction" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Finite", "module": "Mathlib.Data.Finite.Defs" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" }, { "name": "IsGLB", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "And", "module": "Init.Prelude" }, { "name": "IsGreatest", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "lowerBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "upperBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "InfSet", "module": "Mathlib.Order.SetNotation" }, { "name": "iInf", "module": "Mathlib.Order.SetNotation" }, { "name": "LinearOrder", "module": "Mathlib.Order.Defs.LinearOrder" }, { "name": "List.foldl", "module": "Init.Prelude" }, { "name": "List.map", "module": "Init.Prelude" }, { "name": "Sum", "module": "Init.Core" }, { "name": "Sum.inl", "module": "Init.Core" }, { "name": "reduceCtorEq", "module": "Lean.Meta.Tactic.Simp.BuiltinSimprocs.Core" }, { "name": "Set.range", "module": "Mathlib.Data.Set.Operations" } ]
[ { "name": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$", "content": "local macro:max (priority := high) \"β†ͺ\" b:term : term => `(⟨$b, by admit /- proof elided -/\n⟩)" }, { "name": "Block", "content": "inductive Block (K₁ Kβ‚‚ : Type) (C Sigma : Type) (V : Type) [PreWithZero V] where\n \n | deposit (recipient : Kβ‚‚) (amount : Vβ‚Š)\n \n | transfer (aggregator : K₁) (extradata : ExtraDataT) (commitment : C) (senders : List Kβ‚‚) (sigma : Sigma)\n \n | withdrawal (withdrawals : K₁ β†’ Vβ‚Š)" }, { "name": "isWithdrawalBlock", "content": "abbrev isWithdrawalBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.withdrawal _)" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "attach", "content": "noncomputable def attach (Ξ± : Type) [Finite Ξ±] : UniquelyIndexed Ξ± :=\n have := Finite.exists_equiv_fin Ξ±\n this.choose_spec.some.toEmbedding" }, { "name": "UniquelyIndexed", "content": "abbrev UniquelyIndexed (Ξ± : Type) [Finite Ξ±] : Type := Ξ± β†ͺ !Ξ±" }, { "name": "UniqueTokenT", "content": "abbrev UniqueTokenT (Ξ± : Type) [Finite Ξ±] : Type := Fin (Finite.exists_equiv_fin Ξ± |>.choose)" }, { "name": "Ξ€", "content": "abbrev Ξ€ (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { Ο„ : Ξ€' K₁ Kβ‚‚ V // Ο„.isValid }" }, { "name": "Ξ€'", "content": "abbrev Ξ€' (K₁ Kβ‚‚ V : Type) [PreWithZero V] := Kbar K₁ Kβ‚‚ Γ— Kbar K₁ Kβ‚‚ Γ— Option Vβ‚Š" }, { "name": "Kbar", "content": "inductive Kbar (K₁ Kβ‚‚ : Type) where\n | key (k : Key K₁ Kβ‚‚)\n | Source\nderiving DecidableEq" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "BalanceProof", "content": "abbrev BalanceProof (K₁ Kβ‚‚ : Type) [Finite K₁] [Finite Kβ‚‚]\n (C Pi V : Type) [PreWithZero V] : Type :=\n Dict (C Γ— Kβ‚‚) ((Pi Γ— ExtraDataT) Γ— TransactionBatch K₁ Kβ‚‚ V) " }, { "name": "TransactionBatch", "content": "abbrev TransactionBatch (K₁ : Type) [Finite K₁]\n (Kβ‚‚ : Type) [Finite Kβ‚‚]\n (V : Type) [PreWithZero V] :=\n Key K₁ Kβ‚‚ β†’ Vβ‚Š" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "lexLe", "content": "def lexLe (a b : Kβ‚‚ Γ— Key K₁ Kβ‚‚) : Prop :=\n a.1 < b.1 ∨ (a.1 = b.1 ∧ a.2 ≀ b.2)" }, { "name": "isTransferBlock", "content": "abbrev isTransferBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.transfer _ _ _ _ _)" }, { "name": "keys", "content": "def keys (m : Dict Ξ± Ο‰) : Set Ξ± := { x | Dict.is_mem m x }" }, { "name": "Dict.is_mem", "content": "def Dict.is_mem (m : Dict Ξ± Ο‰) (x : Ξ±) : Prop := (m x).isSome" }, { "name": "keys", "content": "abbrev keys (ct : CommitT C K Pi) := ct.dict.keys" }, { "name": "CommitT", "content": "structure CommitT (C K Pi : Type) where\n commitment : C\n dict : Dict K Pi" }, { "name": "keysUneq", "content": "abbrev keysUneq (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) : Prop :=\n match k with\n | .inl _ => True\n | .inr kβ‚‚' => kβ‚‚ β‰  kβ‚‚'" }, { "name": "isDepositBlock", "content": "abbrev isDepositBlock (b : Block K₁ Kβ‚‚ C Sigma V) := b matches (Block.deposit _ _) " }, { "name": "S", "content": "abbrev S (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { s : S' K₁ Kβ‚‚ V // s.isValid }" }, { "name": "S'", "content": "abbrev S' (K₁ Kβ‚‚ V : Type) := Kbar K₁ Kβ‚‚ β†’ V" }, { "name": "Ξ€c", "content": "abbrev Ξ€c (K₁ Kβ‚‚ V : Type) [PreWithZero V] : Type := { Ο„ : Ξ€ K₁ Kβ‚‚ V // Ο„.isComplete }" }, { "name": "isComplete", "content": "def isComplete (Ο„ : Ξ€ K₁ Kβ‚‚ V) :=\n match Ο„ with | ⟨(_, _, v), _⟩ => v.isSome" }, { "name": "getWithdrawal", "content": "def getWithdrawal (b : Block K₁ Kβ‚‚ C Sigma V) (_h : b.isWithdrawalBlock) : K₁ β†’ Vβ‚Š :=\n match b with | .withdrawal B => B" }, { "name": "infix:50 \" β‰ β‚– \" => Key.keysUneq ", "content": "infix:50 \" β‰ β‚– \" => Key.keysUneq " }, { "name": "prefix:max \"!\" => UniqueTokenT", "content": "prefix:max \"!\" => UniqueTokenT" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "Finset.filter_eq'", "module": "Mathlib.Data.Finset.Basic" }, { "name": "Finset.filter_or", "module": "Mathlib.Data.Finset.Basic" }, { "name": "Finset.mem_univ", "module": "Mathlib.Data.Fintype.Defs" }, { "name": "Finset.sum_congr", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Basic" }, { "name": "Finset.sum_const_zero", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Defs" }, { "name": "Finset.sum_ite", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Piecewise" }, { "name": "Finset.sum_singleton", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Basic" }, { "name": "Finset.sum_union", "module": "Mathlib.Algebra.BigOperators.Group.Finset.Basic" }, { "name": "List.foldl_cons", "module": "Init.Data.List.Basic" }, { "name": "List.map_cons", "module": "Init.Data.List.Basic" }, { "name": "List.mem_cons", "module": "Init.Data.List.Lemmas" }, { "name": "Option.get_some", "module": "Init.Data.Option.Basic" }, { "name": "add_assoc", "module": "Mathlib.Algebra.Group.Defs" }, { "name": "add_left_inj", "module": "Mathlib.Algebra.Group.Defs" }, { "name": "add_right_inj", "module": "Mathlib.Algebra.Group.Defs" }, { "name": "add_zero", "module": "Mathlib.Algebra.Group.Defs" }, { "name": "ite_smul", "module": "Mathlib.Algebra.Group.Basic" }, { "name": "neg_smul", "module": "Mathlib.Algebra.Module.Defs" }, { "name": "not_or", "module": "Init.PropLemmas" }, { "name": "one_smul", "module": "Mathlib.Algebra.Group.Action.Defs" }, { "name": "sub_zero", "module": "Mathlib.Algebra.Group.Basic" }, { "name": "zero_smul", "module": "Mathlib.Algebra.GroupWithZero.Action.Defs" }, { "name": "zero_sub", "module": "Mathlib.Algebra.Group.Defs" }, { "name": "Set.image_eq_range", "module": "Mathlib.Data.Set.Image" }, { "name": "if_pos", "module": "Init.Core" }, { "name": "Finset.mem_sort", "module": "Mathlib.Data.Finset.Sort" }, { "name": "List.bind_eq_flatMap", "module": "Mathlib.Data.List.Basic" }, { "name": "List.flatMap_singleton'", "module": "Init.Data.List.Lemmas" }, { "name": "List.flatMap_subtype", "module": "Init.Data.List.Attach" }, { "name": "List.pure_def", "module": "Mathlib.Data.List.Monad" }, { "name": "List.unattach_attach", "module": "Init.Data.List.Attach" }, { "name": "Set.setOf_true", "module": "Mathlib.Data.Set.Basic" }, { "name": "Set.toFinset_univ", "module": "Mathlib.Data.Fintype.Sets" }, { "name": "exists_eq", "module": "Init.PropLemmas" }, { "name": "forall_const", "module": "Init.PropLemmas" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Intmax.TransactionsInBlock_deposit", "content": "def TransactionsInBlock_deposit\n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/\n ⟩]\n | .withdrawal .. | .transfer .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock_transfer", "content": "def TransactionsInBlock_transfer \n (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .transfer _ _ commitment S _ =>\n \n let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) }\n let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe \n \n let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š :=\n if s βˆ‰ S\n then .some 0\n else \n if h : (commitment, s) ∈ Ο€.keys\n then let (_, t) := Ο€[(commitment, s)]\n t r\n else .none\n sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/\n ⟩\n | .deposit .. | .withdrawal .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock_withdrawal", "content": "def TransactionsInBlock_withdrawal \n (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) :=\n match h : b.1 with\n | .withdrawal withdrawals =>\n \n let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·)\n k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/\n ⟩\n | .deposit r v | .transfer .. => by admit /- proof elided -/" }, { "name": "Intmax.TransactionsInBlock", "content": "def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := \n match h : b with\n | .deposit .. => TransactionsInBlock_deposit β†ͺb\n | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb\n | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb" }, { "name": "Intmax.e", "content": "def e (i : Kbar K₁ Kβ‚‚) : Kbar K₁ Kβ‚‚ β†’ β„€ := Ξ» j ↦ if i = j then 1 else 0" }, { "name": "Intmax.v'", "content": "def v' (v : Vβ‚Š) (b : S K₁ Kβ‚‚ V) (s : Kbar K₁ Kβ‚‚) : Vβ‚Š :=\n match h : s with\n | .Source => v\n | .key _ => ⟨v βŠ“ b s, by admit /- proof elided -/\n ⟩" }, { "name": "Intmax.fc", "content": "def fc (Ο„cXb : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨λ k : Kbar K₁ Kβ‚‚ ↦\n match Ο„cXb with\n | ⟨⟨⟨⟨s, r, v⟩, _⟩, hΟ„βŸ©, b⟩ =>\n let v' := v' (v.get hΟ„) b s\n b k + (e r - e s) k β€’ v',\n by admit /- proof elided -/\n ⟩" }, { "name": "Intmax.boundedBelow", "content": "abbrev boundedBelow (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) :=\n { a : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V | (T, b) ≀ (↑a.1, a.2) }" }, { "name": "Intmax.V'", "content": "def V' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) : Set V :=\n { v : V | v ∈ (fc Β· k) '' boundedBelow b T }" }, { "name": "Intmax.f'", "content": "def f' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := \n ⟨\n Ξ» k ↦\n match h : T with\n | ⟨(_, _, .some _), hT⟩ => fc (⟨T, by admit /- proof elided -/\n ⟩, b) k\n | ⟨(s, _, .none), _⟩ => if k = s then 0 else b k,\n by admit /- proof elided -/\n ⟩" }, { "name": "Intmax.exists_inf", "content": "def exists_inf (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : { s : S K₁ Kβ‚‚ V // βˆ€ k, IsGLB (V' b T k) (s k) } :=\n ⟨\n f' b T,\n Ξ» k ↦\n have f'_codomain : (f' b T) k ∈ V' b T k := by admit /- proof elided -/\n ⟩" }, { "name": "Intmax.infV", "content": "def infV (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) :\n InfSet V where\n sInf := Ξ» s ↦ if s = V' b T k\n then (exists_inf b T).1 k\n else 0" }, { "name": "Intmax.f", "content": "def f (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨\n Ξ» k ↦\n have : InfSet V := infV b T k\n β¨… x : boundedBelow b T, fc x.1 k,\n by admit /- proof elided -/\n ⟩" } ]
[ { "name": "Intmax.e_def", "content": "@[simp]\nlemma e_def : e i = Ξ» j ↦ if i = j then 1 else 0" }, { "name": "Intmax.v'_key_eq_meet", "content": "@[simp]\nlemma v'_key_eq_meet {k : Key K₁ Kβ‚‚} : v' v b (Kbar.key k) = ⟨v βŠ“ b k, by simp⟩" }, { "name": "Intmax.V'_eq_range", "content": "private lemma V'_eq_range {b : S K₁ Kβ‚‚ V} {T : Ξ€ K₁ Kβ‚‚ V} {k : Kbar K₁ Kβ‚‚} :\n V' b T k =\n Set.range Ξ» (x : { x : (Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V) // (T, b) ≀ (↑x.1, x.2) }) ↦ fc ↑x k" }, { "name": "Intmax.f_eq_f'", "content": "lemma f_eq_f' : f = f' (K₁ := K₁) (Kβ‚‚ := Kβ‚‚) (V := V)" }, { "name": "Intmax.f_withdrawal_block_source_aux", "content": "omit [Finite Kβ‚‚] [LinearOrder Kβ‚‚] in\nprivate lemma f_withdrawal_block_source_aux {l : List K₁}\n (hβ‚€ : l.Nodup) (h : b.isWithdrawalBlock) :\n (List.foldl f' Οƒ\n (List.map (Ξ» s : K₁ ↦ ⟨(s, Kbar.Source, some (b.getWithdrawal h s)), by unfold Ξ€'.isValid; aesop⟩) l)).1\n .Source = Οƒ .Source + βˆ‘ x : K₁, if x ∈ l then (↑(b.getWithdrawal h x) βŠ“ Οƒ x) else 0" } ]
import Mathlib import Mathlib.Algebra.Group.Int import FVIntmax.BalanceProof import FVIntmax.Block import FVIntmax.Key import FVIntmax.Propositions import FVIntmax.State import FVIntmax.Transaction import FVIntmax.Wheels import FVIntmax.Wheels.Dictionary namespace Intmax noncomputable section open Classical section Balance variable {Pi K₁ Kβ‚‚ V C Sigma : Type} section Extraction section Deposit variable [PreWithZero V] def TransactionsInBlock_deposit (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isDepositBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .deposit r v => [⟨(.Source, r, v), by admit /- proof elided -/ ⟩] | .withdrawal .. | .transfer .. => by admit /- proof elided -/ end Deposit section Transfer variable [Finite K₁] [Finite Kβ‚‚] [LinearOrder K₁] [LinearOrder Kβ‚‚] [PreWithZero V] def TransactionsInBlock_transfer (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isTransferBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .transfer _ _ commitment S _ => let senderRecipient : Finset (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := { (kβ‚‚, k) | (kβ‚‚ : Kβ‚‚) (k : Key K₁ Kβ‚‚) (_h : kβ‚‚ β‰ β‚– k) } let sorted : List (Kβ‚‚ Γ— Key K₁ Kβ‚‚) := senderRecipient.sort Key.lexLe let v (s : Kβ‚‚) (r : Key K₁ Kβ‚‚) : Option Vβ‚Š := if s βˆ‰ S then .some 0 else if h : (commitment, s) ∈ Ο€.keys then let (_, t) := Ο€[(commitment, s)] t r else .none sorted.attach.map Ξ» ⟨(s, r), h⟩ ↦ ⟨(s, r, v s r), by admit /- proof elided -/ ⟩ | .deposit .. | .withdrawal .. => by admit /- proof elided -/ end Transfer section Withdrawal variable [LinearOrder K₁] [Finite K₁] [PreWithZero V] def TransactionsInBlock_withdrawal (b : { b : Block K₁ Kβ‚‚ C Sigma V // b.isWithdrawalBlock }) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b.1 with | .withdrawal withdrawals => let k₁InOrder := { s | s : K₁ }.toFinset.sort (·≀·) k₁InOrder.attach.map Ξ» s : K₁ ↦ ⟨(s, .Source, withdrawals s), by admit /- proof elided -/ ⟩ | .deposit r v | .transfer .. => by admit /- proof elided -/ end Withdrawal variable [Finite K₁] [LinearOrder K₁] [Finite Kβ‚‚] [LinearOrder Kβ‚‚] [PreWithZero V] {b : Block K₁ Kβ‚‚ C Sigma V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} {π₁ Ο€β‚‚ : BalanceProof K₁ Kβ‚‚ C Pi V} def TransactionsInBlock (Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V) (b : Block K₁ Kβ‚‚ C Sigma V) : List (Ξ€ K₁ Kβ‚‚ V) := match h : b with | .deposit .. => TransactionsInBlock_deposit β†ͺb | .transfer .. => TransactionsInBlock_transfer Ο€ β†ͺb | .withdrawal .. => TransactionsInBlock_withdrawal β†ͺb end Extraction section e def e (i : Kbar K₁ Kβ‚‚) : Kbar K₁ Kβ‚‚ β†’ β„€ := Ξ» j ↦ if i = j then 1 else 0 variable {i j : Kbar K₁ Kβ‚‚} end e section WithStructuredTypes section v' variable [Zero V] [Lattice V] -- NB `PreWithZero V` is implied as `CompleteLattice V` gives `Preorder V`. def v' (v : Vβ‚Š) (b : S K₁ Kβ‚‚ V) (s : Kbar K₁ Kβ‚‚) : Vβ‚Š := match h : s with | .Source => v | .key _ => ⟨v βŠ“ b s, by admit /- proof elided -/ ⟩ variable {v : Vβ‚Š} {b : S K₁ Kβ‚‚ V} {s : Kbar K₁ Kβ‚‚} end v' section Fc variable [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] def fc (Ο„cXb : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := ⟨λ k : Kbar K₁ Kβ‚‚ ↦ match Ο„cXb with | ⟨⟨⟨⟨s, r, v⟩, _⟩, hΟ„βŸ©, b⟩ => let v' := v' (v.get hΟ„) b s b k + (e r - e s) k β€’ v', by admit /- proof elided -/ ⟩ variable {Ο„c : Ξ€c K₁ Kβ‚‚ V} {b : S K₁ Kβ‚‚ V} end Fc section Order variable [Lattice V] [AddCommGroup V] end Order section BoundedBelow variable [Lattice V] [AddCommGroup V] abbrev boundedBelow (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) := { a : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V | (T, b) ≀ (↑a.1, a.2) } end BoundedBelow section LGroup variable [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] def V' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) : Set V := { v : V | v ∈ (fc Β· k) '' boundedBelow b T } section f def f' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := ⟨ Ξ» k ↦ match h : T with | ⟨(_, _, .some _), hT⟩ => fc (⟨T, by admit /- proof elided -/ ⟩, b) k | ⟨(s, _, .none), _⟩ => if k = s then 0 else b k, by admit /- proof elided -/ ⟩ def exists_inf (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : { s : S K₁ Kβ‚‚ V // βˆ€ k, IsGLB (V' b T k) (s k) } := ⟨ f' b T, Ξ» k ↦ have f'_codomain : (f' b T) k ∈ V' b T k := by admit /- proof elided -/ ⟩ def infV (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) : InfSet V where sInf := Ξ» s ↦ if s = V' b T k then (exists_inf b T).1 k else 0 def f (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := ⟨ Ξ» k ↦ have : InfSet V := infV b T k β¨… x : boundedBelow b T, fc x.1 k, by admit /- proof elided -/ ⟩ end f section fStar variable {s : S K₁ Kβ‚‚ V} end fStar variable [Finite K₁] [LinearOrder K₁] [Finite Kβ‚‚] [LinearOrder Kβ‚‚] section LocalProperties variable {Οƒ : S K₁ Kβ‚‚ V} {Ο€ : BalanceProof K₁ Kβ‚‚ C Pi V} {T : Ξ€ K₁ Kβ‚‚ V} {b : Block K₁ Kβ‚‚ C Sigma V} {Sigma : Type}
lemma f_withdrawal_block_source (h : b.isWithdrawalBlock) : ((TransactionsInBlock Ο€ b).foldl f Οƒ) .Source = Οƒ .Source + βˆ‘ k : K₁, (b.getWithdrawal h k).1 βŠ“ Οƒ k :=
:= by simp only [TransactionsInBlock] split <;> [simp at h; simp at h; skip] next B => simp only [f_eq_f', TransactionsInBlock_withdrawal, List.pure_def, List.bind_eq_flatMap, exists_eq, Set.setOf_true, Set.toFinset_univ, Finset.mem_sort, Finset.mem_univ, forall_const, List.flatMap_subtype, List.unattach_attach, List.flatMap_singleton', Block.getWithdrawal] have : (Block.withdrawal B).getWithdrawal h = B := by ext k; simp [Block.getWithdrawal] simp_rw [←this] rw [f_withdrawal_block_source_aux (by simp)] simp [Finset.mem_sort]
6
105
false
Applied verif.
214
Intmax.monotone_f
lemma monotone_f (h₁ : b₁ ≀ bβ‚‚) (hβ‚‚ : T₁ ≀ Tβ‚‚) : f b₁ T₁ k ≀ f bβ‚‚ Tβ‚‚ k
FVIntmax
FVIntmax/Lemma4.lean
[ "import FVIntmax.Balance" ]
[ { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "IsGLB", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "And", "module": "Init.Prelude" }, { "name": "IsGreatest", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "lowerBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "upperBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "InfSet", "module": "Mathlib.Order.SetNotation" }, { "name": "iInf", "module": "Mathlib.Order.SetNotation" } ]
[ { "name": "f", "content": "def f (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨\n Ξ» k ↦\n have : InfSet V := infV b T k\n β¨… x : boundedBelow b T, fc x.1 k,\n by admit /- proof elided -/\n ⟩" }, { "name": "infV", "content": "def infV (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) :\n InfSet V where\n sInf := Ξ» s ↦ if s = V' b T k\n then (exists_inf b T).1 k\n else 0" }, { "name": "exists_inf", "content": "def exists_inf (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : { s : S K₁ Kβ‚‚ V // βˆ€ k, IsGLB (V' b T k) (s k) } :=\n ⟨\n f' b T,\n Ξ» k ↦\n have f'_codomain : (f' b T) k ∈ V' b T k := by admit /- proof elided -/\n ⟩" }, { "name": "fc", "content": "def fc (Ο„cXb : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V :=\n ⟨λ k : Kbar K₁ Kβ‚‚ ↦\n match Ο„cXb with\n | ⟨⟨⟨⟨s, r, v⟩, _⟩, hΟ„βŸ©, b⟩ =>\n let v' := v' (v.get hΟ„) b s\n b k + (e r - e s) k β€’ v',\n by admit /- proof elided -/\n ⟩" }, { "name": "e", "content": "def e (i : Kbar K₁ Kβ‚‚) : Kbar K₁ Kβ‚‚ β†’ β„€ := Ξ» j ↦ if i = j then 1 else 0" }, { "name": "Kbar", "content": "inductive Kbar (K₁ Kβ‚‚ : Type) where\n | key (k : Key K₁ Kβ‚‚)\n | Source\nderiving DecidableEq" }, { "name": "Key", "content": "abbrev Key (K₁ Kβ‚‚ : Type) := K₁ βŠ• Kβ‚‚" }, { "name": "S", "content": "abbrev S (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { s : S' K₁ Kβ‚‚ V // s.isValid }" }, { "name": "S'", "content": "abbrev S' (K₁ Kβ‚‚ V : Type) := Kbar K₁ Kβ‚‚ β†’ V" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "Ξ€c", "content": "abbrev Ξ€c (K₁ Kβ‚‚ V : Type) [PreWithZero V] : Type := { Ο„ : Ξ€ K₁ Kβ‚‚ V // Ο„.isComplete }" }, { "name": "Ξ€", "content": "abbrev Ξ€ (K₁ Kβ‚‚ V : Type) [PreWithZero V] := { Ο„ : Ξ€' K₁ Kβ‚‚ V // Ο„.isValid }" }, { "name": "Ξ€'", "content": "abbrev Ξ€' (K₁ Kβ‚‚ V : Type) [PreWithZero V] := Kbar K₁ Kβ‚‚ Γ— Kbar K₁ Kβ‚‚ Γ— Option Vβ‚Š" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "boundedBelow", "content": "abbrev boundedBelow (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) :=\n { a : Ξ€c K₁ Kβ‚‚ V Γ— S K₁ Kβ‚‚ V | (T, b) ≀ (↑a.1, a.2) }" }, { "name": "f'", "content": "def f' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) : S K₁ Kβ‚‚ V := \n ⟨\n Ξ» k ↦\n match h : T with\n | ⟨(_, _, .some _), hT⟩ => fc (⟨T, by admit /- proof elided -/\n ⟩, b) k\n | ⟨(s, _, .none), _⟩ => if k = s then 0 else b k,\n by admit /- proof elided -/\n ⟩" }, { "name": "Injective", "content": "class Injective {Ξ± Ο‰ : Type} (f : Ξ± β†’ Ο‰) where\n h : ComputationallyInfeasible (Β¬ Function.Injective f)" }, { "name": "V'", "content": "def V' (b : S K₁ Kβ‚‚ V) (T : Ξ€ K₁ Kβ‚‚ V) (k : Kbar K₁ Kβ‚‚) : Set V :=\n { v : V | v ∈ (fc Β· k) '' boundedBelow b T }" }, { "name": "isComplete", "content": "def isComplete (Ο„ : Ξ€ K₁ Kβ‚‚ V) :=\n match Ο„ with | ⟨(_, _, v), _⟩ => v.isSome" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "le_isGLB_iff", "module": "Mathlib.Order.Bounds.Basic" }, { "name": "mem_lowerBounds", "module": "Mathlib.Order.Bounds.Basic" } ]
[ { "name": "V'_sset_V'_of_le", "content": "lemma V'_sset_V'_of_le {b₁ bβ‚‚ : S K₁ Kβ‚‚ V} {T₁ Tβ‚‚ : Ξ€ K₁ Kβ‚‚ V} {k : Kbar K₁ Kβ‚‚}\n (h : b₁ ≀ bβ‚‚) (h₁ : T₁ ≀ Tβ‚‚) : \n V' bβ‚‚ Tβ‚‚ k βŠ† V' b₁ T₁ k" }, { "name": "boundedBelow_sset_boundedBelow_of_le", "content": "lemma boundedBelow_sset_boundedBelow_of_le {b₁ bβ‚‚ : S K₁ Kβ‚‚ V} {T₁ Tβ‚‚ : Ξ€ K₁ Kβ‚‚ V}\n (h : b₁ ≀ bβ‚‚) (h₁ : T₁ ≀ Tβ‚‚) : boundedBelow bβ‚‚ Tβ‚‚ βŠ† boundedBelow b₁ T₁" }, { "name": "f_IsGLB_of_V'", "content": "lemma f_IsGLB_of_V' {b : S K₁ Kβ‚‚ V} {T : Ξ€ K₁ Kβ‚‚ V} {k : Kbar K₁ Kβ‚‚} :\n IsGLB (V' b T k) (f b T k)" } ]
[]
[]
import FVIntmax.Balance namespace Intmax open Mathlib noncomputable section Lemma4 section HicSuntDracones section variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [AddCommGroup V] [Lattice V] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} section HelperFunctionsToAppeaseLean open Mathlib open Lean.Elab.Tactic in section variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs : List (Block K₁ Kβ‚‚ C Sigma V)} end end HelperFunctionsToAppeaseLean end section variable {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] [LinearOrder K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs Bstar : List (Block K₁ Kβ‚‚ C Sigma V)} end end HicSuntDracones section variable {n : β„•} {Pi C Sigma : Type} {K₁ : Type} [Finite K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] {Ο€ Ο€' : BalanceProof K₁ Kβ‚‚ C Pi V} {bs Bstar : List (Block K₁ Kβ‚‚ C Sigma V)} section Monotone variable {b₁ bβ‚‚ : S K₁ Kβ‚‚ V} {T₁ Tβ‚‚ : Ξ€ K₁ Kβ‚‚ V} {k : Kbar K₁ Kβ‚‚} {v₁ vβ‚‚ : Vector (Ξ€ K₁ Kβ‚‚ V) n}
lemma monotone_f (h₁ : b₁ ≀ bβ‚‚) (hβ‚‚ : T₁ ≀ Tβ‚‚) : f b₁ T₁ k ≀ f bβ‚‚ Tβ‚‚ k :=
:= by obtain ⟨inf₁, -⟩ := f_IsGLB_of_V' (b := b₁) (T := T₁) (k := k) have infβ‚‚ := f_IsGLB_of_V' (b := bβ‚‚) (T := Tβ‚‚) (k := k) have := V'_sset_V'_of_le (k := k) h₁ hβ‚‚ rw [le_isGLB_iff infβ‚‚, mem_lowerBounds] aesop
8
36
false
Applied verif.
215
Intmax.proposition6
lemma proposition6 [Setoid' Y] {D₁ Dβ‚‚ : Dict X Y} : (βˆƒ join, IsLUB {D₁, Dβ‚‚} join) ↔ βˆ€ x, D₁ x β‰  .none ∧ Dβ‚‚ x β‰  .none β†’ D₁ x β‰… Dβ‚‚ x
FVIntmax
FVIntmax/Propositions.lean
[ "import Mathlib.Order.Bounds.Basic", "import FVIntmax.Wheels.Dictionary", "import Aesop", "import Mathlib.Order.Bounds.Defs", "import Mathlib.Order.Defs" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "IsLUB", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "IsLeast", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "lowerBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "Iff", "module": "Init.Core" }, { "name": "upperBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Set.Ici", "module": "Mathlib.Order.Interval.Set.Defs" }, { "name": "Function.eval", "module": "Mathlib.Logic.Function.Basic" }, { "name": "Set.image", "module": "Mathlib.Data.Set.Defs" } ]
[ { "name": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b", "content": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b" }, { "name": "Merge", "content": "def Merge (D₁ Dβ‚‚ : Dict Ξ± Ο‰) : Dict Ξ± Ο‰ := D\n where D := Ξ» x ↦ First (D₁ x) (Dβ‚‚ x)" }, { "name": "First", "content": "def First (x₁ xβ‚‚ : Option Ξ±) : Option Ξ± :=\n match x₁, xβ‚‚ with\n | .some x, .none => .some x\n | .some x, .some _ => .some x\n | .none, .some y => .some y\n | .none, .none => .none" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "notation:65 π₁:65 \" <+> \" Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚", "content": "notation:65 π₁:65 \" <+> \" Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚" } ]
[ { "name": "le_trans", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "mem_upperBounds", "module": "Mathlib.Order.Bounds.Basic" }, { "name": "isLUB_pi", "module": "Mathlib.Order.Bounds.Image" } ]
[ { "name": "mem_iff_isSome", "content": "lemma mem_iff_isSome {m : Dict Ξ± Ο‰} {x : Ξ±} : x ∈ m ↔ (m x).isSome" } ]
[ { "name": "Intmax.iso", "content": "def iso {X : Type} [Preorder X] (a b : X) := a ≀ b ∧ b ≀ a" }, { "name": "Intmax.IsEquivRel", "content": "def IsEquivRel {X : Type} [Preorder X] := βˆ€ a b : X, a ≀ b ↔ a β‰… b" }, { "name": "Intmax.Setoid'", "content": "class Setoid' (X : Type) extends Preorder X where\n isEquiv : IsEquivRel (X := X)" } ]
[ { "name": "Intmax.iso_rfl", "content": "@[simp, refl]\nlemma iso_rfl : a β‰… a" }, { "name": "Intmax.iso_trans", "content": "@[trans]\nlemma iso_trans : (a β‰… b) β†’ (b β‰… c) β†’ a β‰… c" }, { "name": "Intmax.proposition2", "content": "lemma proposition2 [Setoid' X] {x y : X} :\n (βˆƒ join : X, IsLUB {x, y} join) ↔ x β‰… y" }, { "name": "Intmax.proposition2'", "content": "lemma proposition2' [Setoid' X] {join x y : X} (h : IsLUB {x, y} join) :\n (x β‰… join) ∧ y β‰… join" }, { "name": "Intmax.proposition3'", "content": "lemma proposition3' : \n (βˆƒ join : X, IsLUB {x, y} join) ↔ (βˆƒ join : Option X, IsLUB {.some x, .some y, .none} join)" }, { "name": "Intmax.proposition4", "content": "lemma proposition4 [Setoid' X] {x y : Option X} :\n (βˆƒ join : Option X, IsLUB {x, y, .none} join) ↔ (x β‰  .none ∧ y β‰  .none β†’ x β‰… y)" }, { "name": "Intmax.proposition5", "content": "lemma proposition5 [Preorder Y] {f g : X β†’ Y} {join : X β†’ Y} :\n IsLUB {f, g} join ↔ βˆ€ x : X, IsLUB {f x, g x} (join x)" }, { "name": "Intmax.proposition6_aux", "content": "lemma proposition6_aux [Setoid' Y] {D₁ Dβ‚‚ : Dict X Y}\n (h : βˆ€ k, D₁ k β‰  .none ∧ Dβ‚‚ k β‰  .none β†’ D₁ k β‰… Dβ‚‚ k) : IsLUB {D₁, Dβ‚‚} (Dict.Merge D₁ Dβ‚‚)" } ]
import Mathlib.Order.Bounds.Basic import Mathlib.Order.Bounds.Defs import Mathlib.Order.Defs import Aesop import FVIntmax.Wheels.Dictionary namespace Intmax def iso {X : Type} [Preorder X] (a b : X) := a ≀ b ∧ b ≀ a notation:51 (priority := high) a:52 " β‰… " b:52 => iso a b section iso variable {X : Type} [Preorder X] {a b c : X} end iso def IsEquivRel {X : Type} [Preorder X] := βˆ€ a b : X, a ≀ b ↔ a β‰… b class Setoid' (X : Type) extends Preorder X where isEquiv : IsEquivRel (X := X) section Automation variable {Ξ± : Type} [Preorder Ξ±] {x y : Ξ±} end Automation section Propositions variable {X Y : Type} section proposition3 variable [Preorder X] {x? y? join? join'? : Option X} {x y join join' : X} end proposition3 section Automation variable {X : Type} [Setoid' X] {x y : X} {x? y? : Option X} end Automation
lemma proposition6 [Setoid' Y] {D₁ Dβ‚‚ : Dict X Y} : (βˆƒ join, IsLUB {D₁, Dβ‚‚} join) ↔ βˆ€ x, D₁ x β‰  .none ∧ Dβ‚‚ x β‰  .none β†’ D₁ x β‰… Dβ‚‚ x :=
:= by refine' ⟨λ h ↦ _, Ξ» h ↦ _⟩ simp_rw [proposition5] at h simp_rw [←proposition4] aesop use D₁.Merge Dβ‚‚ exact proposition6_aux h
4
30
false
Applied verif.
216
Intmax.proposition6'
lemma proposition6' [Setoid' Y] {D₁ Dβ‚‚ join : Dict X Y} (h : IsLUB {D₁, Dβ‚‚} join) : join β‰… Dict.Merge D₁ Dβ‚‚
FVIntmax
FVIntmax/Propositions.lean
[ "import Mathlib.Order.Bounds.Basic", "import FVIntmax.Wheels.Dictionary", "import Aesop", "import Mathlib.Order.Bounds.Defs", "import Mathlib.Order.Defs" ]
[ { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "IsLUB", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "Function.eval", "module": "Mathlib.Logic.Function.Basic" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Set.image", "module": "Mathlib.Data.Set.Defs" }, { "name": "Iff", "module": "Init.Core" }, { "name": "IsLeast", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "lowerBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "upperBounds", "module": "Mathlib.Order.Bounds.Defs" }, { "name": "Set.Ici", "module": "Mathlib.Order.Interval.Set.Defs" } ]
[ { "name": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b", "content": "notation:51 (priority := high) a:52 \" β‰… \" b:52 => iso a b" }, { "name": "Merge", "content": "def Merge (D₁ Dβ‚‚ : Dict Ξ± Ο‰) : Dict Ξ± Ο‰ := D\n where D := Ξ» x ↦ First (D₁ x) (Dβ‚‚ x)" }, { "name": "First", "content": "def First (x₁ xβ‚‚ : Option Ξ±) : Option Ξ± :=\n match x₁, xβ‚‚ with\n | .some x, .none => .some x\n | .some x, .some _ => .some x\n | .none, .some y => .some y\n | .none, .none => .none" }, { "name": "Dict", "content": "abbrev Dict (Ξ± Ο‰ : Type) : Type := Ξ± β†’ Option Ο‰" }, { "name": "notation:65 π₁:65 \" <+> \" Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚", "content": "notation:65 π₁:65 \" <+> \" Ο€β‚‚:66 => Dict.Merge π₁ Ο€β‚‚" } ]
[ { "name": "isLUB_pi", "module": "Mathlib.Order.Bounds.Image" }, { "name": "le_trans", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "mem_upperBounds", "module": "Mathlib.Order.Bounds.Basic" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Intmax.iso", "content": "def iso {X : Type} [Preorder X] (a b : X) := a ≀ b ∧ b ≀ a" }, { "name": "Intmax.IsEquivRel", "content": "def IsEquivRel {X : Type} [Preorder X] := βˆ€ a b : X, a ≀ b ↔ a β‰… b" }, { "name": "Intmax.Setoid'", "content": "class Setoid' (X : Type) extends Preorder X where\n isEquiv : IsEquivRel (X := X)" } ]
[ { "name": "Intmax.iso_rfl", "content": "@[simp, refl]\nlemma iso_rfl : a β‰… a" }, { "name": "Intmax.iso_symm", "content": "@[symm]\nlemma iso_symm : (a β‰… b) ↔ b β‰… a" }, { "name": "Intmax.iso_trans", "content": "@[trans]\nlemma iso_trans : (a β‰… b) β†’ (b β‰… c) β†’ a β‰… c" }, { "name": "Intmax.proposition2", "content": "lemma proposition2 [Setoid' X] {x y : X} :\n (βˆƒ join : X, IsLUB {x, y} join) ↔ x β‰… y" }, { "name": "Intmax.proposition2'", "content": "lemma proposition2' [Setoid' X] {join x y : X} (h : IsLUB {x, y} join) :\n (x β‰… join) ∧ y β‰… join" }, { "name": "Intmax.proposition3'", "content": "lemma proposition3' : \n (βˆƒ join : X, IsLUB {x, y} join) ↔ (βˆƒ join : Option X, IsLUB {.some x, .some y, .none} join)" }, { "name": "Intmax.proposition4", "content": "lemma proposition4 [Setoid' X] {x y : Option X} :\n (βˆƒ join : Option X, IsLUB {x, y, .none} join) ↔ (x β‰  .none ∧ y β‰  .none β†’ x β‰… y)" }, { "name": "Intmax.proposition4'", "content": "lemma proposition4' [Setoid' X] {join x y : Option X} (h : IsLUB {x, y, .none} join) :\n join β‰… Dict.First x y" }, { "name": "Intmax.proposition5", "content": "lemma proposition5 [Preorder Y] {f g : X β†’ Y} {join : X β†’ Y} :\n IsLUB {f, g} join ↔ βˆ€ x : X, IsLUB {f x, g x} (join x)" }, { "name": "Intmax.proposition5'", "content": "lemma proposition5' [Preorder Y] {f g h join' : X β†’ Y}\n (hβ‚€ : IsLUB {f, g} join')\n (h₁ : βˆ€ x, h x β‰… join' x) :\n join' β‰… h" } ]
import Mathlib.Order.Bounds.Basic import Mathlib.Order.Bounds.Defs import Mathlib.Order.Defs import Aesop import FVIntmax.Wheels.Dictionary namespace Intmax def iso {X : Type} [Preorder X] (a b : X) := a ≀ b ∧ b ≀ a notation:51 (priority := high) a:52 " β‰… " b:52 => iso a b section iso variable {X : Type} [Preorder X] {a b c : X} end iso def IsEquivRel {X : Type} [Preorder X] := βˆ€ a b : X, a ≀ b ↔ a β‰… b class Setoid' (X : Type) extends Preorder X where isEquiv : IsEquivRel (X := X) section Automation variable {Ξ± : Type} [Preorder Ξ±] {x y : Ξ±} end Automation section Propositions variable {X Y : Type} section proposition3 variable [Preorder X] {x? y? join? join'? : Option X} {x y join join' : X} end proposition3 section Automation variable {X : Type} [Setoid' X] {x y : X} {x? y? : Option X} end Automation
lemma proposition6' [Setoid' Y] {D₁ Dβ‚‚ join : Dict X Y} (h : IsLUB {D₁, Dβ‚‚} join) : join β‰… Dict.Merge D₁ Dβ‚‚ :=
:= by unfold Dict.Merge Dict.Merge.D apply proposition5' (hβ‚€ := h) intros x rw [iso_symm] apply proposition4' revert x rw [proposition5] at h simpa
5
30
false
Applied verif.
217
Intmax.computeBalance'_eq_zero
lemma computeBalance'_eq_zero : computeBalance' Οƒ v = v + computeBalance' Οƒ 0
FVIntmax
FVIntmax/AttackGame.lean
[ "import FVIntmax.Wheels.AuthenticatedDictionary", "import FVIntmax.Request", "import FVIntmax.Block", "import FVIntmax.Wheels.SignatureAggregation", "import FVIntmax.BalanceProof", "import FVIntmax.Wheels" ]
[ { "name": "Sigma", "module": "Init.Core" }, { "name": "Preorder", "module": "Mathlib.Order.Defs.PartialOrder" }, { "name": "Zero", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" } ]
[ { "name": "Block", "content": "inductive Block (K₁ Kβ‚‚ : Type) (C Sigma : Type) (V : Type) [PreWithZero V] where\n \n | deposit (recipient : Kβ‚‚) (amount : Vβ‚Š)\n \n | transfer (aggregator : K₁) (extradata : ExtraDataT) (commitment : C) (senders : List Kβ‚‚) (sigma : Sigma)\n \n | withdrawal (withdrawals : K₁ β†’ Vβ‚Š)" }, { "name": "Scontract", "content": "abbrev Scontract (K₁ Kβ‚‚ V : Type) [PreWithZero V] (C Sigma : Type) :=\n List (Block K₁ Kβ‚‚ C Sigma V)" }, { "name": "ExtraDataT", "content": "abbrev ExtraDataT : Type := β„•" }, { "name": "abbrev", "content": "class abbrev PreWithZero (Ξ± : Type) := Preorder Ξ±, Zero Ξ±" }, { "name": "NonNeg", "content": "def NonNeg (Ξ± : Type) [PreWithZero Ξ±] := { a : Ξ± // 0 ≀ a }" }, { "name": "postfix:max \"β‚Š\" => NonNeg", "content": "postfix:max \"β‚Š\" => NonNeg" } ]
[ { "name": "sub_eq_add_neg", "module": "Mathlib.Algebra.Group.Defs" }, { "name": "add_assoc", "module": "Mathlib.Algebra.Group.Defs" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Intmax.Block.updateBalance", "content": "def Block.updateBalance (bal : V) (block : Block K₁ Kβ‚‚ C Sigma V) : V :=\n match block with\n \n | .deposit _ v => bal + v\n \n | .transfer .. => bal\n \n | .withdrawal B => bal - βˆ‘ k : K₁, (B k).1" }, { "name": "Intmax.computeBalance'", "content": "def computeBalance' (blocks : Scontract K₁ Kβ‚‚ V C Sigma) (acc : V) : V :=\n blocks.foldl Block.updateBalance acc" } ]
[ { "name": "Intmax.Block.updateBalance_eq_zero", "content": "lemma Block.updateBalance_eq_zero :\n block.updateBalance v = v + block.updateBalance 0" }, { "name": "Intmax.computeBalance'_cons", "content": "@[simp]\nlemma computeBalance'_cons : computeBalance' (hd :: Οƒ) v =\n computeBalance' Οƒ (Block.updateBalance v hd)" } ]
import FVIntmax.Wheels.AuthenticatedDictionary import FVIntmax.Wheels.SignatureAggregation import FVIntmax.BalanceProof import FVIntmax.Block import FVIntmax.Request import FVIntmax.Wheels namespace Intmax noncomputable section Intmax section RollupContract open Classical section variable {C : Type} [Nonempty C] {V : Type} [Lattice V] [AddCommGroup V] {K₁ : Type} [Finite K₁] [Nonempty K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] {Sigma : Type} [ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi] [SA : SignatureAggregation (C Γ— K₁ Γ— ExtraDataT) Kβ‚‚ Kβ‚›T Sigma] def Block.updateBalance (bal : V) (block : Block K₁ Kβ‚‚ C Sigma V) : V := match block with | .deposit _ v => bal + v | .transfer .. => bal | .withdrawal B => bal - βˆ‘ k : K₁, (B k).1 end section variable {C : Type} {V : Type} [Lattice V] [AddCommGroup V] {K₁ : Type} [Finite K₁] {Kβ‚‚ : Type} {Sigma : Type} {block : Block K₁ Kβ‚‚ C Sigma V} {v : V} section Lemmas end Lemmas namespace Scontract section variable [LinearOrder K₁] [Nonempty K₁] [LinearOrder Kβ‚‚] [Finite Kβ‚‚] [Nonempty C] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] [ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi] [SignatureAggregation (C Γ— K₁ Γ— ExtraDataT) Kβ‚‚ Kβ‚›T Sigma] section appendBlock variable {Οƒ : Scontract K₁ Kβ‚‚ V C Sigma} {request : Request K₁ Kβ‚‚ C Sigma Pi V} end appendBlock end section variable [LinearOrder K₁] [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {Οƒ : Scontract K₁ Kβ‚‚ V C Sigma} {request : Request K₁ Kβ‚‚ C Sigma Pi V} [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] end end Scontract end end RollupContract section AttackGameDefs variable {K₁ : Type} [Finite K₁] [LinearOrder K₁] [Nonempty K₁] {Kβ‚‚ : Type} [Finite Kβ‚‚] [LinearOrder Kβ‚‚] {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [CovariantClass V V (Function.swap (Β· + Β·)) (Β· ≀ Β·)] {Sigma : Type} {C : Type} [Nonempty C] [ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi] [SignatureAggregation (C Γ— K₁ Γ— ExtraDataT) Kβ‚‚ Kβ‚›T Sigma] (requests : List (Request K₁ Kβ‚‚ C Sigma Pi V)) (Οƒ : Scontract K₁ Kβ‚‚ V C Sigma) def computeBalance' (blocks : Scontract K₁ Kβ‚‚ V C Sigma) (acc : V) : V := blocks.foldl Block.updateBalance acc end AttackGameDefs section AttackGameLemmas variable {K₁ Kβ‚‚ Sigma C : Type} {V : Type} [Lattice V] [AddCommGroup V] [CovariantClass V V (Β· + Β·) (Β· ≀ Β·)] [ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi] section computeBalanceSum variable {k : β„•} end computeBalanceSum variable [Finite K₁] end AttackGameLemmas section ComputeLemmas variable {K₁ : Type} [Finite K₁] {Kβ‚‚ Sigma C : Type} {V : Type} [Lattice V] [AddCommGroup V] {Οƒ : Scontract K₁ Kβ‚‚ V C Sigma} [ADScheme Kβ‚‚ (C Γ— K₁ Γ— ExtraDataT) C Pi]
lemma computeBalance'_eq_zero : computeBalance' Οƒ v = v + computeBalance' Οƒ 0 :=
:= by induction' Οƒ with hd tl ih generalizing v Β· simp Β· rw [computeBalance'_cons, computeBalance'_cons, ih, Block.updateBalance_eq_zero] nth_rw 2 [ih] exact add_assoc v _ _
3
15
false
Applied verif.
218
evalFuel_sound
theorem evalFuel_sound : evalFuel n c = some v β†’ c ″⋆ v
IntroEffects
IntroEffects/Eval.lean
[ "import IntroEffects.SmallStep" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "ite", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Computation", "module": "Mathlib.Data.Seq.Computation" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Max", "module": "Init.Prelude" }, { "name": "Max.max", "module": "Init.Prelude" } ]
[ { "name": "scoped syntax num : embedded", "content": "scoped syntax num : embedded" }, { "name": "instantiateComp", "content": "def instantiateComp (what : Value) (comp : Computation) : Computation :=\n instantiateComputationLvl what 0 comp" }, { "name": "instantiateComputationLvl", "content": "def instantiateComputationLvl (what : Value) (level : Nat) : Computation β†’ Computation\n| .ret v => .ret <| instantiateValueLvl what level v\n| .opCall op v c => .opCall op (instantiateValueLvl what level v) (instantiateComputationLvl what (level+1) c)\n| .bind c₁ cβ‚‚ => .bind (instantiateComputationLvl what level c₁) (instantiateComputationLvl what (level+1) cβ‚‚)\n| .ite v c₁ cβ‚‚ => .ite (instantiateValueLvl what level v) (instantiateComputationLvl what level c₁) (instantiateComputationLvl what level cβ‚‚)\n| .app v₁ vβ‚‚ => .app (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .handle v c => .handle (instantiateValueLvl what level v) (instantiateComputationLvl what level c)\n| .join v₁ vβ‚‚ => .join (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .fst v => .fst (instantiateValueLvl what level v)\n| .snd v => .snd (instantiateValueLvl what level v)\n| .add v₁ vβ‚‚ => .add (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .sub v₁ vβ‚‚ => .sub (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .max v₁ vβ‚‚ => .max (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .lt v₁ vβ‚‚ => .lt (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .mul v₁ vβ‚‚ => .mul (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .eq v₁ vβ‚‚ => .eq (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\ntermination_by c => sizeOf c\ndecreasing_by\n all_goals simp\n all_goals grind" }, { "name": "instantiateValueLvl", "content": "def instantiateValueLvl (what : Value) (level : Nat) : Value β†’ Value\n| var@(.var (.bvar bvarLevel)) => if bvarLevel = level then what else var\n| .lam c => .lam <| instantiateComputationLvl what (level + 1) c\n| .hdl h => .hdl <| instantiateHandlerLvl what level h\n| .pair v₁ vβ‚‚ => .pair (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .recfun c => .recfun <| instantiateComputationLvl what (level + 2) c\n| .string s => .string s\n| .bool b => .bool b\n| .unit => .unit\n| .var v => .var v\n| .num n => .num n\ntermination_by v => sizeOf v\ndecreasing_by\n all_goals simp\n all_goals grind" }, { "name": "instantiateHandlerLvl", "content": "def instantiateHandlerLvl (what : Value) (level : Nat) : Handler β†’ Handler\n| ⟨ret, ops'⟩ =>\n ⟨instantiateComputationLvl what (level+1) ret, instantiateOps what level ops'⟩\ntermination_by h => sizeOf h\ndecreasing_by\n all_goals simp\n all_goals grind" }, { "name": "instantiateOps", "content": "def instantiateOps (what : Value) (level : Nat) : List OpClause β†’ List OpClause\n| [] => []\n| ⟨op, body⟩ :: ls =>\n ⟨op, instantiateComputationLvl what (level+2) body⟩ :: instantiateOps what level ls\ntermination_by l => sizeOf l" }, { "name": "OpClause", "content": "structure OpClause where\n op : Name\n \n body : Computation\nderiving Repr, BEq" }, { "name": "Computation", "content": "inductive Computation where\n| ret : Value β†’ Computation\n \n| opCall : Name β†’ Value β†’ Computation β†’ Computation\n \n| bind : Computation β†’ Computation β†’ Computation\n| ite (val : Value) (trueBranch falseBranch : Computation)\n| app : Value β†’ Value β†’ Computation\n \n| handle : Value β†’ Computation β†’ Computation\n| join : Value β†’ Value β†’ Computation\n| fst : Value β†’ Computation\n| snd : Value β†’ Computation\n| add : Value β†’ Value β†’ Computation\n| sub : Value β†’ Value β†’ Computation\n| mul : Value β†’ Value β†’ Computation\n| max : Value β†’ Value β†’ Computation\n| lt : Value β†’ Value β†’ Computation\n| eq : Value β†’ Value β†’ Computation\nderiving BEq" }, { "name": "Value", "content": "inductive Value where\n| var : Var β†’ Value\n| bool : Bool β†’ Value\n| string : String β†’ Value\n| num : Int β†’ Value\n| unit : Value\n| pair : Value β†’ Value β†’ Value\n \n| lam : Computation β†’ Value\n \n| recfun : Computation β†’ Value\n| hdl : Handler β†’ Value\nderiving BEq" }, { "name": "Handler", "content": "structure Handler where\n \n ret : Computation\n ops : List OpClause\nderiving Repr, BEq" }, { "name": "Var", "content": "inductive Var where\n| fvar : Name β†’ Var\n| bvar : Nat β†’ Var\nderiving Repr, DecidableEq" }, { "name": "Name", "content": "abbrev Name := String" }, { "name": "Step", "content": "@[grind cases]\ninductive Step : Computation β†’ Computation β†’ Prop\n \n| beta v body : Step (.app (.lam body) v) (instantiateComp v body)\n \n| recBeta v body : Step (.app (.recfun body) v) (instantiate2 (.recfun body) v body)\n \n| iteTrue c₁ cβ‚‚ : Step (.ite (.bool true) c₁ cβ‚‚) c₁\n \n| iteFalse c₁ cβ‚‚ : Step (.ite (.bool false) c₁ cβ‚‚) cβ‚‚\n \n| bindStep c₁ c₁' cβ‚‚ (h : Step c₁ c₁') : Step (.bind c₁ cβ‚‚) (.bind c₁' cβ‚‚)\n \n| bindReturn v c : Step (.bind (.ret v) c) (instantiateComp v c)\n \n| bindOp op v body c : Step (.bind (.opCall op v body) c) (.opCall op v (.bind body c))\n \n| handleInner h c₁ cβ‚‚ (h₁ : Step c₁ cβ‚‚) : Step (.handle (.hdl h) c₁) (.handle (.hdl h) cβ‚‚)\n \n| handleReturn h v :\n Step (.handle (.hdl h) (.ret v)) (instantiateComp v h.ret)\n \n| handleOpHit h op v body c (hop : h.lookup op = some ⟨op, c⟩) :\n Step (.handle (.hdl h) (.opCall op v body))\n (instantiate2 v (.lam (.handle (.hdl h) body)) c)\n \n| handleOpMiss h op v body (hop : h.lookup op = none) :\n Step (.handle (.hdl h) (.opCall op v body)) (.opCall op v (.handle (.hdl h) body))\n \n| join s₁ sβ‚‚ : Step (.join (.string s₁) (.string sβ‚‚)) (.ret (.string (strAppend s₁ sβ‚‚)))\n \n| fstStep v₁ vβ‚‚ : Step (.fst (.pair v₁ vβ‚‚)) (.ret v₁)\n \n| sndStep v₁ vβ‚‚ : Step (.snd (.pair v₁ vβ‚‚)) (.ret vβ‚‚)\n| add v₁ vβ‚‚ : Step (.add (.num v₁) (.num vβ‚‚)) (.ret (.num (v₁ + vβ‚‚)))\n| sub v₁ vβ‚‚ : Step (.sub (.num v₁) (.num vβ‚‚)) (.ret (.num (v₁ - vβ‚‚)))\n| max v₁ vβ‚‚ : Step (.max (.num v₁) (.num vβ‚‚)) (.ret (.num (Max.max v₁ vβ‚‚)))\n| lt v₁ vβ‚‚ : Step (.lt (.num v₁) (.num vβ‚‚)) (.ret (.bool (v₁ < vβ‚‚)))\n| mul v₁ vβ‚‚ : Step (.mul (.num v₁) (.num vβ‚‚)) (.ret (.num (v₁ * vβ‚‚)))\n| eq v₁ vβ‚‚ : Step (.eq v₁ vβ‚‚) (.ret (.bool (v₁ == vβ‚‚)))" }, { "name": "instantiate2", "content": "def instantiate2 (arg cont : Value) (body : Computation) : Computation :=\n instantiateComputationLvl arg 1 (instantiateComputationLvl cont 0 body)" }, { "name": "strAppend", "content": "def strAppend : String β†’ String β†’ String\n| \"\", s => s\n| s, \"\" => s\n| s₁, sβ‚‚ => s₁ ++ \" \" ++ sβ‚‚" }, { "name": "StepStar", "content": "@[grind cases]\ninductive StepStar : Computation β†’ Computation β†’ Prop\n| refl (c) : StepStar c c\n| trans : Step c₁ cβ‚‚ β†’ StepStar cβ‚‚ c₃ β†’ StepStar c₁ c₃" }, { "name": "Handler.lookup", "content": "def Handler.lookup (hdl : Handler) (name : Name) :=\n hdl.ops.find? (Β·.op == name)" }, { "name": "infix:50 \" β€³ \" => Step", "content": "infix:50 \" β€³ \" => Step" }, { "name": "infix:50 \" ″⋆ \" => StepStar", "content": "infix:50 \" ″⋆ \" => StepStar" } ]
[ { "name": "List.find?_some", "module": "Init.Data.List.Find" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "evalSingleStep", "content": "def evalSingleStep : Computation β†’ Option Computation\n \n| .app (.lam body) v => some <| instantiateComp v body\n \n| .app (.recfun body) v => some <| instantiate2 (.recfun body) v body\n| .ite (.bool true) c₁ _ => some c₁\n| .ite (.bool false) _ cβ‚‚ => some cβ‚‚\n \n| .bind (.ret v) c => some <| instantiateComp v c\n \n| .bind (.opCall op v body) c => some <| .opCall op v (.bind body c)\n| .bind c₁ cβ‚‚ => (evalSingleStep c₁).map (fun c₁' => .bind c₁' cβ‚‚)\n \n| .handle (.hdl h) (.ret v) => some <| instantiateComp v h.ret\n| .handle (.hdl h) (.opCall op v body) =>\n match h.lookup op with\n \n | some ⟨_, c⟩ =>\n let cont := .lam (.handle (.hdl h) body)\n some <| instantiate2 v cont c\n \n | none => some <| .opCall op v (.handle (.hdl h) body)\n| .handle (.hdl h) c =>\n (evalSingleStep c).map (fun c' => .handle (.hdl h) c')\n| .join (.string s₁) (.string sβ‚‚) => some <| .ret (.string (strAppend s₁ sβ‚‚))\n| .fst (.pair v₁ _) => some <| .ret v₁\n| .snd (.pair _ vβ‚‚) => some <| .ret vβ‚‚\n| .add (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ + vβ‚‚))\n| .sub (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ - vβ‚‚))\n| .max (.num v₁) (.num vβ‚‚) => some <| .ret (.num (Max.max v₁ vβ‚‚))\n| .lt (.num v₁) (.num vβ‚‚) => some <| .ret (.bool (v₁ < vβ‚‚))\n| .mul (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ * vβ‚‚))\n| .eq v₁ vβ‚‚ => some <| .ret (.bool (v₁ == vβ‚‚))\n| _ => none" }, { "name": "evalFuel", "content": "def evalFuel : Nat β†’ Computation β†’ Option Computation\n| 0, _ => none\n| _+1, .ret v => some <| .ret v\n| _+1, .opCall n v c => some <| .opCall n v c\n| n+1, c =>\n match evalSingleStep c with\n | some c' => evalFuel n c'\n | none => none" } ]
[ { "name": "evalSingleStep_sound", "content": "theorem evalSingleStep_sound {c c' : Computation} :\n evalSingleStep c = some c' β†’ c β€³ c'" } ]
import IntroEffects.SmallStep def evalSingleStep : Computation β†’ Option Computation | .app (.lam body) v => some <| instantiateComp v body | .app (.recfun body) v => some <| instantiate2 (.recfun body) v body | .ite (.bool true) c₁ _ => some c₁ | .ite (.bool false) _ cβ‚‚ => some cβ‚‚ | .bind (.ret v) c => some <| instantiateComp v c | .bind (.opCall op v body) c => some <| .opCall op v (.bind body c) | .bind c₁ cβ‚‚ => (evalSingleStep c₁).map (fun c₁' => .bind c₁' cβ‚‚) | .handle (.hdl h) (.ret v) => some <| instantiateComp v h.ret | .handle (.hdl h) (.opCall op v body) => match h.lookup op with | some ⟨_, c⟩ => let cont := .lam (.handle (.hdl h) body) some <| instantiate2 v cont c | none => some <| .opCall op v (.handle (.hdl h) body) | .handle (.hdl h) c => (evalSingleStep c).map (fun c' => .handle (.hdl h) c') | .join (.string s₁) (.string sβ‚‚) => some <| .ret (.string (strAppend s₁ sβ‚‚)) | .fst (.pair v₁ _) => some <| .ret v₁ | .snd (.pair _ vβ‚‚) => some <| .ret vβ‚‚ | .add (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ + vβ‚‚)) | .sub (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ - vβ‚‚)) | .max (.num v₁) (.num vβ‚‚) => some <| .ret (.num (Max.max v₁ vβ‚‚)) | .lt (.num v₁) (.num vβ‚‚) => some <| .ret (.bool (v₁ < vβ‚‚)) | .mul (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ * vβ‚‚)) | .eq v₁ vβ‚‚ => some <| .ret (.bool (v₁ == vβ‚‚)) | _ => none def evalFuel : Nat β†’ Computation β†’ Option Computation | 0, _ => none | _+1, .ret v => some <| .ret v | _+1, .opCall n v c => some <| .opCall n v c | n+1, c => match evalSingleStep c with | some c' => evalFuel n c' | none => none
theorem evalFuel_sound : evalFuel n c = some v β†’ c ″⋆ v :=
:= by induction h : n generalizing c with | zero => simp [evalFuel] | succ n ih => cases hstep : evalSingleStep c with | none => cases c <;> try grind [evalFuel] all_goals ( simp [evalFuel] intro h; rw [←h]; constructor) | some c' => cases c with | ret | opCall => simp [evalFuel] intro h; rw [←h]; constructor | _ => simp [evalFuel, hstep] intro h exact StepStar.trans (evalSingleStep_sound hstep) (evalFuel_sound h)
8
34
false
Semantics
219
evalFuelRet_complete_aux
theorem evalFuelRet_complete_aux (h : c ″⋆ r) : βˆ€v, r= .ret v β†’ βˆƒn, evalFuel n c = some (.ret v)
IntroEffects
IntroEffects/Eval.lean
[ "import IntroEffects.SmallStep" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "ite", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Computation", "module": "Mathlib.Data.Seq.Computation" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Max", "module": "Init.Prelude" }, { "name": "Max.max", "module": "Init.Prelude" } ]
[ { "name": "scoped syntax num : embedded", "content": "scoped syntax num : embedded" }, { "name": "instantiateComp", "content": "def instantiateComp (what : Value) (comp : Computation) : Computation :=\n instantiateComputationLvl what 0 comp" }, { "name": "instantiateComputationLvl", "content": "def instantiateComputationLvl (what : Value) (level : Nat) : Computation β†’ Computation\n| .ret v => .ret <| instantiateValueLvl what level v\n| .opCall op v c => .opCall op (instantiateValueLvl what level v) (instantiateComputationLvl what (level+1) c)\n| .bind c₁ cβ‚‚ => .bind (instantiateComputationLvl what level c₁) (instantiateComputationLvl what (level+1) cβ‚‚)\n| .ite v c₁ cβ‚‚ => .ite (instantiateValueLvl what level v) (instantiateComputationLvl what level c₁) (instantiateComputationLvl what level cβ‚‚)\n| .app v₁ vβ‚‚ => .app (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .handle v c => .handle (instantiateValueLvl what level v) (instantiateComputationLvl what level c)\n| .join v₁ vβ‚‚ => .join (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .fst v => .fst (instantiateValueLvl what level v)\n| .snd v => .snd (instantiateValueLvl what level v)\n| .add v₁ vβ‚‚ => .add (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .sub v₁ vβ‚‚ => .sub (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .max v₁ vβ‚‚ => .max (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .lt v₁ vβ‚‚ => .lt (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .mul v₁ vβ‚‚ => .mul (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .eq v₁ vβ‚‚ => .eq (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\ntermination_by c => sizeOf c\ndecreasing_by\n all_goals simp\n all_goals grind" }, { "name": "instantiateValueLvl", "content": "def instantiateValueLvl (what : Value) (level : Nat) : Value β†’ Value\n| var@(.var (.bvar bvarLevel)) => if bvarLevel = level then what else var\n| .lam c => .lam <| instantiateComputationLvl what (level + 1) c\n| .hdl h => .hdl <| instantiateHandlerLvl what level h\n| .pair v₁ vβ‚‚ => .pair (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .recfun c => .recfun <| instantiateComputationLvl what (level + 2) c\n| .string s => .string s\n| .bool b => .bool b\n| .unit => .unit\n| .var v => .var v\n| .num n => .num n\ntermination_by v => sizeOf v\ndecreasing_by\n all_goals simp\n all_goals grind" }, { "name": "instantiateHandlerLvl", "content": "def instantiateHandlerLvl (what : Value) (level : Nat) : Handler β†’ Handler\n| ⟨ret, ops'⟩ =>\n ⟨instantiateComputationLvl what (level+1) ret, instantiateOps what level ops'⟩\ntermination_by h => sizeOf h\ndecreasing_by\n all_goals simp\n all_goals grind" }, { "name": "instantiateOps", "content": "def instantiateOps (what : Value) (level : Nat) : List OpClause β†’ List OpClause\n| [] => []\n| ⟨op, body⟩ :: ls =>\n ⟨op, instantiateComputationLvl what (level+2) body⟩ :: instantiateOps what level ls\ntermination_by l => sizeOf l" }, { "name": "OpClause", "content": "structure OpClause where\n op : Name\n \n body : Computation\nderiving Repr, BEq" }, { "name": "Computation", "content": "inductive Computation where\n| ret : Value β†’ Computation\n \n| opCall : Name β†’ Value β†’ Computation β†’ Computation\n \n| bind : Computation β†’ Computation β†’ Computation\n| ite (val : Value) (trueBranch falseBranch : Computation)\n| app : Value β†’ Value β†’ Computation\n \n| handle : Value β†’ Computation β†’ Computation\n| join : Value β†’ Value β†’ Computation\n| fst : Value β†’ Computation\n| snd : Value β†’ Computation\n| add : Value β†’ Value β†’ Computation\n| sub : Value β†’ Value β†’ Computation\n| mul : Value β†’ Value β†’ Computation\n| max : Value β†’ Value β†’ Computation\n| lt : Value β†’ Value β†’ Computation\n| eq : Value β†’ Value β†’ Computation\nderiving BEq" }, { "name": "Value", "content": "inductive Value where\n| var : Var β†’ Value\n| bool : Bool β†’ Value\n| string : String β†’ Value\n| num : Int β†’ Value\n| unit : Value\n| pair : Value β†’ Value β†’ Value\n \n| lam : Computation β†’ Value\n \n| recfun : Computation β†’ Value\n| hdl : Handler β†’ Value\nderiving BEq" }, { "name": "Handler", "content": "structure Handler where\n \n ret : Computation\n ops : List OpClause\nderiving Repr, BEq" }, { "name": "Var", "content": "inductive Var where\n| fvar : Name β†’ Var\n| bvar : Nat β†’ Var\nderiving Repr, DecidableEq" }, { "name": "Name", "content": "abbrev Name := String" }, { "name": "Step", "content": "@[grind cases]\ninductive Step : Computation β†’ Computation β†’ Prop\n \n| beta v body : Step (.app (.lam body) v) (instantiateComp v body)\n \n| recBeta v body : Step (.app (.recfun body) v) (instantiate2 (.recfun body) v body)\n \n| iteTrue c₁ cβ‚‚ : Step (.ite (.bool true) c₁ cβ‚‚) c₁\n \n| iteFalse c₁ cβ‚‚ : Step (.ite (.bool false) c₁ cβ‚‚) cβ‚‚\n \n| bindStep c₁ c₁' cβ‚‚ (h : Step c₁ c₁') : Step (.bind c₁ cβ‚‚) (.bind c₁' cβ‚‚)\n \n| bindReturn v c : Step (.bind (.ret v) c) (instantiateComp v c)\n \n| bindOp op v body c : Step (.bind (.opCall op v body) c) (.opCall op v (.bind body c))\n \n| handleInner h c₁ cβ‚‚ (h₁ : Step c₁ cβ‚‚) : Step (.handle (.hdl h) c₁) (.handle (.hdl h) cβ‚‚)\n \n| handleReturn h v :\n Step (.handle (.hdl h) (.ret v)) (instantiateComp v h.ret)\n \n| handleOpHit h op v body c (hop : h.lookup op = some ⟨op, c⟩) :\n Step (.handle (.hdl h) (.opCall op v body))\n (instantiate2 v (.lam (.handle (.hdl h) body)) c)\n \n| handleOpMiss h op v body (hop : h.lookup op = none) :\n Step (.handle (.hdl h) (.opCall op v body)) (.opCall op v (.handle (.hdl h) body))\n \n| join s₁ sβ‚‚ : Step (.join (.string s₁) (.string sβ‚‚)) (.ret (.string (strAppend s₁ sβ‚‚)))\n \n| fstStep v₁ vβ‚‚ : Step (.fst (.pair v₁ vβ‚‚)) (.ret v₁)\n \n| sndStep v₁ vβ‚‚ : Step (.snd (.pair v₁ vβ‚‚)) (.ret vβ‚‚)\n| add v₁ vβ‚‚ : Step (.add (.num v₁) (.num vβ‚‚)) (.ret (.num (v₁ + vβ‚‚)))\n| sub v₁ vβ‚‚ : Step (.sub (.num v₁) (.num vβ‚‚)) (.ret (.num (v₁ - vβ‚‚)))\n| max v₁ vβ‚‚ : Step (.max (.num v₁) (.num vβ‚‚)) (.ret (.num (Max.max v₁ vβ‚‚)))\n| lt v₁ vβ‚‚ : Step (.lt (.num v₁) (.num vβ‚‚)) (.ret (.bool (v₁ < vβ‚‚)))\n| mul v₁ vβ‚‚ : Step (.mul (.num v₁) (.num vβ‚‚)) (.ret (.num (v₁ * vβ‚‚)))\n| eq v₁ vβ‚‚ : Step (.eq v₁ vβ‚‚) (.ret (.bool (v₁ == vβ‚‚)))" }, { "name": "instantiate2", "content": "def instantiate2 (arg cont : Value) (body : Computation) : Computation :=\n instantiateComputationLvl arg 1 (instantiateComputationLvl cont 0 body)" }, { "name": "strAppend", "content": "def strAppend : String β†’ String β†’ String\n| \"\", s => s\n| s, \"\" => s\n| s₁, sβ‚‚ => s₁ ++ \" \" ++ sβ‚‚" }, { "name": "StepStar", "content": "@[grind cases]\ninductive StepStar : Computation β†’ Computation β†’ Prop\n| refl (c) : StepStar c c\n| trans : Step c₁ cβ‚‚ β†’ StepStar cβ‚‚ c₃ β†’ StepStar c₁ c₃" }, { "name": "infix:50 \" β€³ \" => Step", "content": "infix:50 \" β€³ \" => Step" }, { "name": "infix:50 \" ″⋆ \" => StepStar", "content": "infix:50 \" ″⋆ \" => StepStar" } ]
[ { "name": "trans", "module": "Mathlib.Order.Defs.Unbundled" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "evalSingleStep", "content": "def evalSingleStep : Computation β†’ Option Computation\n \n| .app (.lam body) v => some <| instantiateComp v body\n \n| .app (.recfun body) v => some <| instantiate2 (.recfun body) v body\n| .ite (.bool true) c₁ _ => some c₁\n| .ite (.bool false) _ cβ‚‚ => some cβ‚‚\n \n| .bind (.ret v) c => some <| instantiateComp v c\n \n| .bind (.opCall op v body) c => some <| .opCall op v (.bind body c)\n| .bind c₁ cβ‚‚ => (evalSingleStep c₁).map (fun c₁' => .bind c₁' cβ‚‚)\n \n| .handle (.hdl h) (.ret v) => some <| instantiateComp v h.ret\n| .handle (.hdl h) (.opCall op v body) =>\n match h.lookup op with\n \n | some ⟨_, c⟩ =>\n let cont := .lam (.handle (.hdl h) body)\n some <| instantiate2 v cont c\n \n | none => some <| .opCall op v (.handle (.hdl h) body)\n| .handle (.hdl h) c =>\n (evalSingleStep c).map (fun c' => .handle (.hdl h) c')\n| .join (.string s₁) (.string sβ‚‚) => some <| .ret (.string (strAppend s₁ sβ‚‚))\n| .fst (.pair v₁ _) => some <| .ret v₁\n| .snd (.pair _ vβ‚‚) => some <| .ret vβ‚‚\n| .add (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ + vβ‚‚))\n| .sub (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ - vβ‚‚))\n| .max (.num v₁) (.num vβ‚‚) => some <| .ret (.num (Max.max v₁ vβ‚‚))\n| .lt (.num v₁) (.num vβ‚‚) => some <| .ret (.bool (v₁ < vβ‚‚))\n| .mul (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ * vβ‚‚))\n| .eq v₁ vβ‚‚ => some <| .ret (.bool (v₁ == vβ‚‚))\n| _ => none" }, { "name": "evalFuel", "content": "def evalFuel : Nat β†’ Computation β†’ Option Computation\n| 0, _ => none\n| _+1, .ret v => some <| .ret v\n| _+1, .opCall n v c => some <| .opCall n v c\n| n+1, c =>\n match evalSingleStep c with\n | some c' => evalFuel n c'\n | none => none" } ]
[ { "name": "evalSingleStep_complete", "content": "theorem evalSingleStep_complete {c c' : Computation} :\n c β€³ c' β†’ evalSingleStep c = (some c')" }, { "name": "evalFuel_step", "content": "theorem evalFuel_step (h : c β€³ c') : evalFuel (n + 1) c = evalFuel n c'" } ]
import IntroEffects.SmallStep def evalSingleStep : Computation β†’ Option Computation | .app (.lam body) v => some <| instantiateComp v body | .app (.recfun body) v => some <| instantiate2 (.recfun body) v body | .ite (.bool true) c₁ _ => some c₁ | .ite (.bool false) _ cβ‚‚ => some cβ‚‚ | .bind (.ret v) c => some <| instantiateComp v c | .bind (.opCall op v body) c => some <| .opCall op v (.bind body c) | .bind c₁ cβ‚‚ => (evalSingleStep c₁).map (fun c₁' => .bind c₁' cβ‚‚) | .handle (.hdl h) (.ret v) => some <| instantiateComp v h.ret | .handle (.hdl h) (.opCall op v body) => match h.lookup op with | some ⟨_, c⟩ => let cont := .lam (.handle (.hdl h) body) some <| instantiate2 v cont c | none => some <| .opCall op v (.handle (.hdl h) body) | .handle (.hdl h) c => (evalSingleStep c).map (fun c' => .handle (.hdl h) c') | .join (.string s₁) (.string sβ‚‚) => some <| .ret (.string (strAppend s₁ sβ‚‚)) | .fst (.pair v₁ _) => some <| .ret v₁ | .snd (.pair _ vβ‚‚) => some <| .ret vβ‚‚ | .add (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ + vβ‚‚)) | .sub (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ - vβ‚‚)) | .max (.num v₁) (.num vβ‚‚) => some <| .ret (.num (Max.max v₁ vβ‚‚)) | .lt (.num v₁) (.num vβ‚‚) => some <| .ret (.bool (v₁ < vβ‚‚)) | .mul (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ * vβ‚‚)) | .eq v₁ vβ‚‚ => some <| .ret (.bool (v₁ == vβ‚‚)) | _ => none def evalFuel : Nat β†’ Computation β†’ Option Computation | 0, _ => none | _+1, .ret v => some <| .ret v | _+1, .opCall n v c => some <| .opCall n v c | n+1, c => match evalSingleStep c with | some c' => evalFuel n c' | none => none
theorem evalFuelRet_complete_aux (h : c ″⋆ r) : βˆ€v, r= .ret v β†’ βˆƒn, evalFuel n c = some (.ret v) :=
:= by induction h with | refl c' => intro v hv exact ⟨1, by grind [evalFuel]⟩ | @trans c1 c2 c3 hStep hTail ih => intro v hv obtain ⟨n, ihFuel⟩ := ih v hv refine ⟨n+1, ?_⟩ simp [evalFuel_step hStep, ihFuel]
8
34
false
Semantics
220
evalFuelOpCall_complete_aux
theorem evalFuelOpCall_complete_aux (h : c ″⋆ r) : βˆ€v, r = .opCall name v comp β†’ βˆƒn, evalFuel n c = some (.opCall name v comp)
IntroEffects
IntroEffects/Eval.lean
[ "import IntroEffects.SmallStep" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "ite", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Computation", "module": "Mathlib.Data.Seq.Computation" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Max", "module": "Init.Prelude" }, { "name": "Max.max", "module": "Init.Prelude" } ]
[ { "name": "scoped syntax num : embedded", "content": "scoped syntax num : embedded" }, { "name": "instantiateComp", "content": "def instantiateComp (what : Value) (comp : Computation) : Computation :=\n instantiateComputationLvl what 0 comp" }, { "name": "instantiateComputationLvl", "content": "def instantiateComputationLvl (what : Value) (level : Nat) : Computation β†’ Computation\n| .ret v => .ret <| instantiateValueLvl what level v\n| .opCall op v c => .opCall op (instantiateValueLvl what level v) (instantiateComputationLvl what (level+1) c)\n| .bind c₁ cβ‚‚ => .bind (instantiateComputationLvl what level c₁) (instantiateComputationLvl what (level+1) cβ‚‚)\n| .ite v c₁ cβ‚‚ => .ite (instantiateValueLvl what level v) (instantiateComputationLvl what level c₁) (instantiateComputationLvl what level cβ‚‚)\n| .app v₁ vβ‚‚ => .app (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .handle v c => .handle (instantiateValueLvl what level v) (instantiateComputationLvl what level c)\n| .join v₁ vβ‚‚ => .join (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .fst v => .fst (instantiateValueLvl what level v)\n| .snd v => .snd (instantiateValueLvl what level v)\n| .add v₁ vβ‚‚ => .add (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .sub v₁ vβ‚‚ => .sub (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .max v₁ vβ‚‚ => .max (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .lt v₁ vβ‚‚ => .lt (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .mul v₁ vβ‚‚ => .mul (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .eq v₁ vβ‚‚ => .eq (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\ntermination_by c => sizeOf c\ndecreasing_by\n all_goals simp\n all_goals grind" }, { "name": "instantiateValueLvl", "content": "def instantiateValueLvl (what : Value) (level : Nat) : Value β†’ Value\n| var@(.var (.bvar bvarLevel)) => if bvarLevel = level then what else var\n| .lam c => .lam <| instantiateComputationLvl what (level + 1) c\n| .hdl h => .hdl <| instantiateHandlerLvl what level h\n| .pair v₁ vβ‚‚ => .pair (instantiateValueLvl what level v₁) (instantiateValueLvl what level vβ‚‚)\n| .recfun c => .recfun <| instantiateComputationLvl what (level + 2) c\n| .string s => .string s\n| .bool b => .bool b\n| .unit => .unit\n| .var v => .var v\n| .num n => .num n\ntermination_by v => sizeOf v\ndecreasing_by\n all_goals simp\n all_goals grind" }, { "name": "instantiateHandlerLvl", "content": "def instantiateHandlerLvl (what : Value) (level : Nat) : Handler β†’ Handler\n| ⟨ret, ops'⟩ =>\n ⟨instantiateComputationLvl what (level+1) ret, instantiateOps what level ops'⟩\ntermination_by h => sizeOf h\ndecreasing_by\n all_goals simp\n all_goals grind" }, { "name": "instantiateOps", "content": "def instantiateOps (what : Value) (level : Nat) : List OpClause β†’ List OpClause\n| [] => []\n| ⟨op, body⟩ :: ls =>\n ⟨op, instantiateComputationLvl what (level+2) body⟩ :: instantiateOps what level ls\ntermination_by l => sizeOf l" }, { "name": "OpClause", "content": "structure OpClause where\n op : Name\n \n body : Computation\nderiving Repr, BEq" }, { "name": "Computation", "content": "inductive Computation where\n| ret : Value β†’ Computation\n \n| opCall : Name β†’ Value β†’ Computation β†’ Computation\n \n| bind : Computation β†’ Computation β†’ Computation\n| ite (val : Value) (trueBranch falseBranch : Computation)\n| app : Value β†’ Value β†’ Computation\n \n| handle : Value β†’ Computation β†’ Computation\n| join : Value β†’ Value β†’ Computation\n| fst : Value β†’ Computation\n| snd : Value β†’ Computation\n| add : Value β†’ Value β†’ Computation\n| sub : Value β†’ Value β†’ Computation\n| mul : Value β†’ Value β†’ Computation\n| max : Value β†’ Value β†’ Computation\n| lt : Value β†’ Value β†’ Computation\n| eq : Value β†’ Value β†’ Computation\nderiving BEq" }, { "name": "Value", "content": "inductive Value where\n| var : Var β†’ Value\n| bool : Bool β†’ Value\n| string : String β†’ Value\n| num : Int β†’ Value\n| unit : Value\n| pair : Value β†’ Value β†’ Value\n \n| lam : Computation β†’ Value\n \n| recfun : Computation β†’ Value\n| hdl : Handler β†’ Value\nderiving BEq" }, { "name": "Handler", "content": "structure Handler where\n \n ret : Computation\n ops : List OpClause\nderiving Repr, BEq" }, { "name": "Var", "content": "inductive Var where\n| fvar : Name β†’ Var\n| bvar : Nat β†’ Var\nderiving Repr, DecidableEq" }, { "name": "Name", "content": "abbrev Name := String" }, { "name": "Step", "content": "@[grind cases]\ninductive Step : Computation β†’ Computation β†’ Prop\n \n| beta v body : Step (.app (.lam body) v) (instantiateComp v body)\n \n| recBeta v body : Step (.app (.recfun body) v) (instantiate2 (.recfun body) v body)\n \n| iteTrue c₁ cβ‚‚ : Step (.ite (.bool true) c₁ cβ‚‚) c₁\n \n| iteFalse c₁ cβ‚‚ : Step (.ite (.bool false) c₁ cβ‚‚) cβ‚‚\n \n| bindStep c₁ c₁' cβ‚‚ (h : Step c₁ c₁') : Step (.bind c₁ cβ‚‚) (.bind c₁' cβ‚‚)\n \n| bindReturn v c : Step (.bind (.ret v) c) (instantiateComp v c)\n \n| bindOp op v body c : Step (.bind (.opCall op v body) c) (.opCall op v (.bind body c))\n \n| handleInner h c₁ cβ‚‚ (h₁ : Step c₁ cβ‚‚) : Step (.handle (.hdl h) c₁) (.handle (.hdl h) cβ‚‚)\n \n| handleReturn h v :\n Step (.handle (.hdl h) (.ret v)) (instantiateComp v h.ret)\n \n| handleOpHit h op v body c (hop : h.lookup op = some ⟨op, c⟩) :\n Step (.handle (.hdl h) (.opCall op v body))\n (instantiate2 v (.lam (.handle (.hdl h) body)) c)\n \n| handleOpMiss h op v body (hop : h.lookup op = none) :\n Step (.handle (.hdl h) (.opCall op v body)) (.opCall op v (.handle (.hdl h) body))\n \n| join s₁ sβ‚‚ : Step (.join (.string s₁) (.string sβ‚‚)) (.ret (.string (strAppend s₁ sβ‚‚)))\n \n| fstStep v₁ vβ‚‚ : Step (.fst (.pair v₁ vβ‚‚)) (.ret v₁)\n \n| sndStep v₁ vβ‚‚ : Step (.snd (.pair v₁ vβ‚‚)) (.ret vβ‚‚)\n| add v₁ vβ‚‚ : Step (.add (.num v₁) (.num vβ‚‚)) (.ret (.num (v₁ + vβ‚‚)))\n| sub v₁ vβ‚‚ : Step (.sub (.num v₁) (.num vβ‚‚)) (.ret (.num (v₁ - vβ‚‚)))\n| max v₁ vβ‚‚ : Step (.max (.num v₁) (.num vβ‚‚)) (.ret (.num (Max.max v₁ vβ‚‚)))\n| lt v₁ vβ‚‚ : Step (.lt (.num v₁) (.num vβ‚‚)) (.ret (.bool (v₁ < vβ‚‚)))\n| mul v₁ vβ‚‚ : Step (.mul (.num v₁) (.num vβ‚‚)) (.ret (.num (v₁ * vβ‚‚)))\n| eq v₁ vβ‚‚ : Step (.eq v₁ vβ‚‚) (.ret (.bool (v₁ == vβ‚‚)))" }, { "name": "instantiate2", "content": "def instantiate2 (arg cont : Value) (body : Computation) : Computation :=\n instantiateComputationLvl arg 1 (instantiateComputationLvl cont 0 body)" }, { "name": "strAppend", "content": "def strAppend : String β†’ String β†’ String\n| \"\", s => s\n| s, \"\" => s\n| s₁, sβ‚‚ => s₁ ++ \" \" ++ sβ‚‚" }, { "name": "StepStar", "content": "@[grind cases]\ninductive StepStar : Computation β†’ Computation β†’ Prop\n| refl (c) : StepStar c c\n| trans : Step c₁ cβ‚‚ β†’ StepStar cβ‚‚ c₃ β†’ StepStar c₁ c₃" }, { "name": "infix:50 \" β€³ \" => Step", "content": "infix:50 \" β€³ \" => Step" }, { "name": "infix:50 \" ″⋆ \" => StepStar", "content": "infix:50 \" ″⋆ \" => StepStar" } ]
[ { "name": "trans", "module": "Mathlib.Order.Defs.Unbundled" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "evalSingleStep", "content": "def evalSingleStep : Computation β†’ Option Computation\n \n| .app (.lam body) v => some <| instantiateComp v body\n \n| .app (.recfun body) v => some <| instantiate2 (.recfun body) v body\n| .ite (.bool true) c₁ _ => some c₁\n| .ite (.bool false) _ cβ‚‚ => some cβ‚‚\n \n| .bind (.ret v) c => some <| instantiateComp v c\n \n| .bind (.opCall op v body) c => some <| .opCall op v (.bind body c)\n| .bind c₁ cβ‚‚ => (evalSingleStep c₁).map (fun c₁' => .bind c₁' cβ‚‚)\n \n| .handle (.hdl h) (.ret v) => some <| instantiateComp v h.ret\n| .handle (.hdl h) (.opCall op v body) =>\n match h.lookup op with\n \n | some ⟨_, c⟩ =>\n let cont := .lam (.handle (.hdl h) body)\n some <| instantiate2 v cont c\n \n | none => some <| .opCall op v (.handle (.hdl h) body)\n| .handle (.hdl h) c =>\n (evalSingleStep c).map (fun c' => .handle (.hdl h) c')\n| .join (.string s₁) (.string sβ‚‚) => some <| .ret (.string (strAppend s₁ sβ‚‚))\n| .fst (.pair v₁ _) => some <| .ret v₁\n| .snd (.pair _ vβ‚‚) => some <| .ret vβ‚‚\n| .add (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ + vβ‚‚))\n| .sub (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ - vβ‚‚))\n| .max (.num v₁) (.num vβ‚‚) => some <| .ret (.num (Max.max v₁ vβ‚‚))\n| .lt (.num v₁) (.num vβ‚‚) => some <| .ret (.bool (v₁ < vβ‚‚))\n| .mul (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ * vβ‚‚))\n| .eq v₁ vβ‚‚ => some <| .ret (.bool (v₁ == vβ‚‚))\n| _ => none" }, { "name": "evalFuel", "content": "def evalFuel : Nat β†’ Computation β†’ Option Computation\n| 0, _ => none\n| _+1, .ret v => some <| .ret v\n| _+1, .opCall n v c => some <| .opCall n v c\n| n+1, c =>\n match evalSingleStep c with\n | some c' => evalFuel n c'\n | none => none" } ]
[ { "name": "evalSingleStep_complete", "content": "theorem evalSingleStep_complete {c c' : Computation} :\n c β€³ c' β†’ evalSingleStep c = (some c')" }, { "name": "evalFuel_step", "content": "theorem evalFuel_step (h : c β€³ c') : evalFuel (n + 1) c = evalFuel n c'" } ]
import IntroEffects.SmallStep def evalSingleStep : Computation β†’ Option Computation | .app (.lam body) v => some <| instantiateComp v body | .app (.recfun body) v => some <| instantiate2 (.recfun body) v body | .ite (.bool true) c₁ _ => some c₁ | .ite (.bool false) _ cβ‚‚ => some cβ‚‚ | .bind (.ret v) c => some <| instantiateComp v c | .bind (.opCall op v body) c => some <| .opCall op v (.bind body c) | .bind c₁ cβ‚‚ => (evalSingleStep c₁).map (fun c₁' => .bind c₁' cβ‚‚) | .handle (.hdl h) (.ret v) => some <| instantiateComp v h.ret | .handle (.hdl h) (.opCall op v body) => match h.lookup op with | some ⟨_, c⟩ => let cont := .lam (.handle (.hdl h) body) some <| instantiate2 v cont c | none => some <| .opCall op v (.handle (.hdl h) body) | .handle (.hdl h) c => (evalSingleStep c).map (fun c' => .handle (.hdl h) c') | .join (.string s₁) (.string sβ‚‚) => some <| .ret (.string (strAppend s₁ sβ‚‚)) | .fst (.pair v₁ _) => some <| .ret v₁ | .snd (.pair _ vβ‚‚) => some <| .ret vβ‚‚ | .add (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ + vβ‚‚)) | .sub (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ - vβ‚‚)) | .max (.num v₁) (.num vβ‚‚) => some <| .ret (.num (Max.max v₁ vβ‚‚)) | .lt (.num v₁) (.num vβ‚‚) => some <| .ret (.bool (v₁ < vβ‚‚)) | .mul (.num v₁) (.num vβ‚‚) => some <| .ret (.num (v₁ * vβ‚‚)) | .eq v₁ vβ‚‚ => some <| .ret (.bool (v₁ == vβ‚‚)) | _ => none def evalFuel : Nat β†’ Computation β†’ Option Computation | 0, _ => none | _+1, .ret v => some <| .ret v | _+1, .opCall n v c => some <| .opCall n v c | n+1, c => match evalSingleStep c with | some c' => evalFuel n c' | none => none
theorem evalFuelOpCall_complete_aux (h : c ″⋆ r) : βˆ€v, r = .opCall name v comp β†’ βˆƒn, evalFuel n c = some (.opCall name v comp) :=
:= by induction h with | refl c' => intro v hv exact ⟨1, by grind [evalFuel]⟩ | @trans c1 c2 c3 hStep hTail ih => intro v hv obtain ⟨n, ihFuel⟩ := ih v hv refine ⟨n+1, ?_⟩ simp [evalFuel_step hStep, ihFuel]
8
34
false
Semantics
221
Iris.Agree.op_inv
theorem Agree.op_inv {x y : Agree Ξ±} : (x.op y).valid β†’ x ≑ y
iris-lean
src/Iris/Algebra/Agree.lean
[ "import Iris.Algebra.CMRA", "import src.Iris.Algebra.CMRA", "import src.Iris.Algebra.OFE", "import Iris.Algebra.OFE" ]
[ { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x", "content": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y" }, { "name": "Agree", "content": "@[ext]\nstructure Agree where\n car : List Ξ±\n not_nil : car β‰  []" }, { "name": "LeibnizO", "content": "@[ext] structure LeibnizO (Ξ± : Type _) where\n car : Ξ±" }, { "name": "op", "content": "abbrev op (x y : Ξ± Γ— Ξ²) : Ξ± Γ— Ξ² :=\n (x.1 β€’ y.1, x.2 β€’ y.2)" }, { "name": "valid", "content": "def valid : DFrac F β†’ Prop\n | .own f => Proper f\n | .discard => True\n | .ownDiscard f => Fractional f" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "Fractional", "content": "def Fractional [Fraction Ξ±] (a : Ξ±) : Prop := βˆƒ b, Proper (a + b)" }, { "name": "Fraction", "content": "class Fraction (Ξ± : Type _) extends Add Ξ± where\n \n Proper : Ξ± β†’ Prop\n add_comm : βˆ€ a b : Ξ±, a + b = b + a\n add_assoc : βˆ€ a b c : Ξ±, a + (b + c) = (a + b) + c\n add_left_cancel : βˆ€ {a b c : Ξ±}, a + b = a + c β†’ b = c\n \n add_ne : βˆ€ {a b : Ξ±}, a β‰  b + a\n proper_add_mono_left : βˆ€ {a b : Ξ±}, Proper (a + b) β†’ Proper a" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Iso.symm", "content": "def Iso.symm [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : Iso Ξ² Ξ± where\n hom := iso.inv\n inv := iso.hom\n hom_inv := by admit /- proof elided -/" }, { "name": "Iso", "content": "@[ext] structure Iso (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n hom : Ξ± -n> Ξ²\n inv : Ξ² -n> Ξ±\n hom_inv : hom (inv x) ≑ x\n inv_hom : inv (hom x) ≑ x" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" } ]
[ { "name": "List.mem_append", "module": "Init.Data.List.Lemmas" } ]
[ { "name": "_root_.Iris.OFE.Dist.validN", "content": "theorem _root_.Iris.OFE.Dist.validN : (x : Ξ±) ≑{n}≑ y β†’ (βœ“{n} x ↔ βœ“{n} y)" }, { "name": "validN_iff", "content": "theorem validN_iff {x y : Ξ±} (e : x ≑{n}≑ y) : βœ“{n} x ↔ βœ“{n} y" }, { "name": "IncludedN.validN", "content": "theorem IncludedN.validN {n} {x y : Ξ±} : x β‰Ό{n} y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "validN_of_incN", "content": "theorem validN_of_incN {n} {x y : Ξ±} : x β‰Ό{n} y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "Included.validN", "content": "theorem Included.validN {n} {x y : Ξ±} : x β‰Ό y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "validN_of_inc", "content": "theorem validN_of_inc {n} {x y : Ξ±} : x β‰Ό y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "Valid.validN", "content": "theorem Valid.validN : βœ“ (x : Ξ±) β†’ βœ“{n} x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "_root_.Iris.OFE.Dist.op", "content": "theorem _root_.Iris.OFE.Dist.op {x x' y y' : Ξ±}\n (ex : x ≑{n}≑ x') (ey : y ≑{n}≑ y') : x β€’ y ≑{n}≑ x' β€’ y'" }, { "name": "Included.trans", "content": "theorem Included.trans : (x : Ξ±) β‰Ό y β†’ y β‰Ό z β†’ x β‰Ό z" }, { "name": "inc_trans", "content": "theorem inc_trans {x y z : Ξ±} : x β‰Ό y β†’ y β‰Ό z β†’ x β‰Ό z" }, { "name": "op_left_eqv", "content": "theorem op_left_eqv {x y : Ξ±} (z : Ξ±) (e : x ≑ y) : x β€’ z ≑ y β€’ z" }, { "name": "_root_.Iris.OFE.Dist.op_r", "content": "theorem _root_.Iris.OFE.Dist.op_r {x y z : Ξ±} : y ≑{n}≑ z β†’ x β€’ y ≑{n}≑ x β€’ z" }, { "name": "op_right_dist", "content": "theorem op_right_dist (x : Ξ±) {y z : Ξ±} (e : y ≑{n}≑ z) : x β€’ y ≑{n}≑ x β€’ z" }, { "name": "_root_.Iris.OFE.Equiv.op_r", "content": "theorem _root_.Iris.OFE.Equiv.op_r {x y z : Ξ±} : y ≑ z β†’ x β€’ y ≑ x β€’ z" }, { "name": "op_right_eqv", "content": "theorem op_right_eqv (x : Ξ±) {y z : Ξ±} (e : y ≑ z) : x β€’ y ≑ x β€’ z" }, { "name": "IncludedN.trans", "content": "theorem IncludedN.trans : (x : Ξ±) β‰Ό{n} y β†’ y β‰Ό{n} z β†’ x β‰Ό{n} z" }, { "name": "incN_trans", "content": "theorem incN_trans {x y z : Ξ±} : x β‰Ό{n} y β†’ y β‰Ό{n} z β†’ x β‰Ό{n} z" }, { "name": "op_left_dist", "content": "theorem op_left_dist {x y : Ξ±} (z : Ξ±) (e : x ≑{n}≑ y) : x β€’ z ≑{n}≑ y β€’ z" }, { "name": "_root_.Iris.OFE.Dist.op_l", "content": "theorem _root_.Iris.OFE.Dist.op_l {x y z : Ξ±} : x ≑{n}≑ y β†’ x β€’ z ≑{n}≑ y β€’ z" }, { "name": "_root_.Iris.OFE.Equiv.op_l", "content": "theorem _root_.Iris.OFE.Equiv.op_l {x y z : Ξ±} : x ≑ y β†’ x β€’ z ≑ y β€’ z" }, { "name": "_root_.Iris.OFE.Equiv.op", "content": "theorem _root_.Iris.OFE.Equiv.op : (x : Ξ±) ≑ x' β†’ y ≑ y' β†’ x β€’ y ≑ x' β€’ y'" }, { "name": "op_eqv", "content": "theorem op_eqv {x x' y y' : Ξ±} (ex : x ≑ x') (ey : y ≑ y') : x β€’ y ≑ x' β€’ y'" } ]
[ { "name": "Iris.Agree", "content": "@[ext]\nstructure Agree where\n car : List Ξ±\n not_nil : car β‰  []" }, { "name": "Iris.Agree.dist", "content": "def Agree.dist (n : Nat) (x y : Agree Ξ±) : Prop :=\n (βˆ€ a ∈ x.car, βˆƒ b ∈ y.car, a ≑{n}≑ b) ∧\n (βˆ€ b ∈ y.car, βˆƒ a ∈ x.car, a ≑{n}≑ b)" }, { "name": "Iris.Agree.validN", "content": "def Agree.validN (n : Nat) (x : Agree Ξ±) : Prop :=\n match x.car with\n | [_] => True\n | _ => βˆ€ a ∈ x.car, βˆ€ b ∈ x.car, a ≑{n}≑ b" }, { "name": "Iris.Agree.op", "content": "def Agree.op (x y : Agree Ξ±) : Agree Ξ± :=\n ⟨x.car ++ y.car, by admit /- proof elided -/\n ⟩" } ]
[ { "name": "Iris.mem_of_agree", "content": "theorem mem_of_agree (x : Agree Ξ±) : βˆƒ a, a ∈ x.car" }, { "name": "Iris.Agree.equiv_def", "content": "theorem Agree.equiv_def {x y : Agree Ξ±} : x ≑ y ↔ βˆ€ n, Agree.dist n x y" }, { "name": "Iris.Agree.validN_iff", "content": "theorem Agree.validN_iff {x : Agree Ξ±} :\n x.validN n ↔ βˆ€ a ∈ x.car, βˆ€ b ∈ x.car, a ≑{n}≑ b" }, { "name": "Iris.Agree.op_invN", "content": "theorem Agree.op_invN {x y : Agree Ξ±} : (x.op y).validN n β†’ x ≑{n}≑ y" } ]
import Iris.Algebra.CMRA import Iris.Algebra.OFE namespace Iris section agree variable {Ξ± : Type u} variable (Ξ±) in @[ext] structure Agree where car : List Ξ± not_nil : car β‰  [] variable [OFE Ξ±] def Agree.dist (n : Nat) (x y : Agree Ξ±) : Prop := (βˆ€ a ∈ x.car, βˆƒ b ∈ y.car, a ≑{n}≑ b) ∧ (βˆ€ b ∈ y.car, βˆƒ a ∈ x.car, a ≑{n}≑ b) def Agree.validN (n : Nat) (x : Agree Ξ±) : Prop := match x.car with | [_] => True | _ => βˆ€ a ∈ x.car, βˆ€ b ∈ x.car, a ≑{n}≑ b def Agree.valid (x : Agree Ξ±) : Prop := βˆ€ n, x.validN n def Agree.op (x y : Agree Ξ±) : Agree Ξ± := ⟨x.car ++ y.car, by admit /- proof elided -/ ⟩
theorem Agree.op_inv {x y : Agree Ξ±} : (x.op y).valid β†’ x ≑ y :=
:= by simp [valid, equiv_def] intro h n exact op_invN (h n)
8
58
false
Framework
222
Iris.OFE.ContractiveHom.fixpoint_ind
@[elab_as_elim] theorem OFE.ContractiveHom.fixpoint_ind [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) (P : Ξ± β†’ Prop) (HProper : βˆ€ A B : Ξ±, A ≑ B β†’ P A β†’ P B) (x : Ξ±) (Hbase : P x) (Hind : βˆ€ x, P x β†’ P (f x)) (Hlim : LimitPreserving P) : P f.fixpoint
iris-lean
src/Iris/Algebra/OFE.lean
[ "import src/Iris/Algebra/Excl.lean", "import src/Iris/Algebra/Agree.lean", "import src/Iris/Algebra/UPred.lean", "import src/Iris/Algebra/COFESolver.lean", "import src/Iris/Instances/UPred/Instance.lean", "import src/Iris/Algebra/Agree_task.lean", "import src/Iris/Algebra/CMRA.lean", "import src/Iris/Algebra/Heap.lean" ]
[ { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Dist", "module": "Mathlib.Topology.MetricSpace.Pseudo.Defs" }, { "name": "Equiv", "module": "Mathlib.Logic.Equiv.Defs" }, { "name": "Nat.succ", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "k", "module": "QqTest.matching" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "", "content": "instance : OFE.Discrete (DFrac F) := ⟨congrArg id⟩" }, { "name": "Agree.dist", "content": "def Agree.dist (n : Nat) (x y : Agree Ξ±) : Prop :=\n (βˆ€ a ∈ x.car, βˆƒ b ∈ y.car, a ≑{n}≑ b) ∧\n (βˆ€ b ∈ y.car, βˆƒ a ∈ x.car, a ≑{n}≑ b)" }, { "name": "", "content": "instance : OFE (Tower F) where\n Equiv f g := βˆ€ k, f k ≑ g k\n Dist n f g := βˆ€ k, f k ≑{n}≑ g k\n dist_eqv := {\n refl _ _ := dist_eqv.refl _\n symm h _ := dist_eqv.symm (h _)\n trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _)\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "", "content": "instance : OFE.NonExpansive (BUpd.bupd (PROP := UPred M)) := bupd_ne" }, { "name": "bupd_ne", "content": "instance bupd_ne : OFE.NonExpansive (bupd : UPred M β†’ UPred M) where\n ne n x1 x2 Hx m y Hm Hv := by admit /- proof elided -/" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "later_contractive", "content": "instance later_contractive : OFE.Contractive UPred.later (Ξ± := UPred M) where\n distLater_dist {n x y} Hl :=\n match n with\n | 0 => by admit /- proof elided -/\n | n + 1 => fun\n | 0 => by admit /- proof elided -/\n | n' + 1 => fun x' Hn' Hx' => Hl _ Hn' _ _ (Nat.le_refl _) (CMRA.validN_succ Hx')" }, { "name": "later", "content": "protected def later (P : UPred M) : UPred M where\n holds n x := match n with | 0 => True | Nat.succ n' => P n' x\n mono {n₁ nβ‚‚} := by admit /- proof elided -/" }, { "name": "BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "BIUpdate", "content": "class BIUpdate (PROP : Type _) [BI PROP] extends BUpd PROP where\n [bupd_ne : OFE.NonExpansive (BUpd.bupd (PROP := PROP))]\n intro {P : PROP} : iprop(P ⊒ |==> P)\n mono {P Q : PROP} : iprop(P ⊒ Q) β†’ iprop(|==> P ⊒ |==> Q)\n trans {P : PROP} : iprop(|==> |==> P ⊒ |==> P)\n frame_r {P R : PROP} : iprop((|==> P) βˆ— R ⊒ |==> (P βˆ— R))" }, { "name": "UPred", "content": "@[ext]\nstructure UPred (M : Type _) [UCMRA M] where\n holds : Nat β†’ M β†’ Prop\n mono {n1 n2 x1 x2} : holds n1 x1 β†’ x1 β‰Ό{n2} x2 β†’ n2 ≀ n1 β†’ holds n2 x2" }, { "name": "IsModal", "content": "class IsModal [BI PROP1] [BI PROP2] (M : PROP1 β†’ PROP2)\n (iaction saction : ModalityAction PROP1 PROP2) where\n spec_intuitionistic : iaction.intuitionistic_action_spec M\n spec_spatial : saction.spatial_action_spec M\n emp : iprop(emp) ⊒ M iprop(emp)\n mono : βˆ€ {P Q}, (P ⊒ Q) β†’ M P ⊒ M Q\n sep : βˆ€ {P Q}, iprop(M P βˆ— M Q) ⊒ M iprop(P βˆ— Q)" }, { "name": "UCMRA", "content": "class UCMRA (Ξ± : Type _) extends CMRA Ξ± where\n unit : Ξ±\n unit_valid : βœ“ unit\n unit_left_id : unit β€’ x ≑ x\n pcore_unit : pcore unit ≑ some unit" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "instOFE", "content": "instance instOFE [Store T K V] [OFE V] : OFE T where\n Equiv s0 s1 := get s0 ≑ get s1\n Dist n s0 s1 := get s0 ≑{n}≑ get s1\n dist_eqv := ⟨fun _ => .of_eq rfl, (Β·.symm), (Β·.trans Β·)⟩\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Store.Equiv", "content": "@[simp] def Store.Equiv [Store T K V] (t1 t2 : T) : Prop := get t1 = get t2" }, { "name": "Store.Equiv_trans", "content": "instance Store.Equiv_trans [Store T K V] : Trans Equiv (Equiv (T := T)) Equiv := ⟨by admit /- proof elided -/\n⟩" }, { "name": "[CMRA", "content": "instance [CMRA Ξ²] : OFE (Ξ± -C> Ξ²) where\n Equiv f g := f.toHom ≑ g.toHom\n Dist n f g := f.toHom ≑{n}≑ g.toHom\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "[OFE", "content": "instance [OFE Ξ±] [IsCOFE Ξ±] : IsCOFE (Excl Ξ±) where\n compl c := (c 0).map fun x => IsCOFE.compl (exclChain c x)\n conv_compl {n} c := by admit /- proof elided -/" }, { "name": "toAgree", "content": "def toAgree (a : Ξ±) : Agree Ξ± := ⟨[a], by admit /- proof elided -/\n⟩" }, { "name": "Agree", "content": "@[ext]\nstructure Agree where\n car : List Ξ±\n not_nil : car β‰  []" }, { "name": "(k", "content": "instance (k : Nat) : NonExpansive (fun X : Tower F => X.val k) := ⟨fun _ _ _ => (Β· _)⟩" }, { "name": "[OFE", "content": "instance [OFE Ξ±] : NonExpansive excl (Ξ± := Ξ±) where\n ne _ _ _ a := a" }, { "name": "get_ne", "content": "instance get_ne [Store T K V] [OFE V] (k : K) : NonExpansive (get Β· k : T β†’ V) where\n ne {_ _ _} Ht := Ht k" }, { "name": "[Store", "content": "instance [Store T1 K V1] [Store T2 K V2] [OFE V1] [OFE V2] (f : K β†’ V1 β†’ V2)\n [βˆ€ k, NonExpansive (f k)] [HasStoreMap T1 T2 K V1 V2] : NonExpansive (dmap f : T1 β†’ T2) where\n ne _ {_ _} H k := by admit /- proof elided -/" }, { "name": "HasStoreMap", "content": "class HasStoreMap (T1 T2 : Type _) (K V1 V2 : outParam (Type _)) [Store T1 K V1] [Store T2 K V2] where\n \n dmap (f : K β†’ V1 β†’ V2) : T1 β†’ T2\n get_dmap : get (dmap f t) k = f k (get t k)" }, { "name": "", "content": "instance : NonExpansive (pcore (Ξ± := Ξ±)) where\n ne n x {y} e := by admit /- proof elided -/" }, { "name": "[Heap", "content": "instance [Heap T K V] [OFE V] (op : V β†’ V β†’ V) [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (merge (T := T) op) where\n ne _ {_ _} Ht {_ _} Hs k := by admit /- proof elided -/" }, { "name": "Heap.instCOFE", "content": "instance Heap.instCOFE [Heap T K V] [COFE V] : COFE T where\n compl c := hmap (fun _ => COFE.compl <| c.map ⟨_, Store.get_ne ·⟩) (c 0)\n conv_compl {_ c} k := by admit /- proof elided -/" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -C> \" => Hom" } ]
[ { "name": "Nat.lt_of_le_of_ne", "module": "Init.Prelude" }, { "name": "Nat.le_of_lt_succ", "module": "Init.Prelude" }, { "name": "Nat.lt_succ_self", "module": "Init.Prelude" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Iris.OFE", "content": "class OFE (Ξ± : Type _) where\n Equiv : Ξ± β†’ Ξ± β†’ Prop\n Dist : Nat β†’ Ξ± β†’ Ξ± β†’ Prop\n dist_eqv : Equivalence (Dist n)\n equiv_dist : Equiv x y ↔ βˆ€ n, Dist n x y\n dist_lt : Dist n x y β†’ m < n β†’ Dist m x y" }, { "name": "Iris.OFE.NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "Iris.OFE.id_ne", "content": "instance id_ne [OFE Ξ±] : NonExpansive (@id Ξ±) := ⟨fun _ _ _ h => h⟩" }, { "name": "Iris.OFE.NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "Iris.OFE.DistLater", "content": "def DistLater [OFE Ξ±] (n : Nat) (x y : Ξ±) : Prop := βˆ€ m, m < n β†’ x ≑{m}≑ y" }, { "name": "Iris.OFE.Contractive", "content": "class Contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n distLater_dist : DistLater n x y β†’ f x ≑{n}≑ f y" }, { "name": "Iris.OFE.ne_of_contractive", "content": "instance ne_of_contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] : NonExpansive f where\n ne := fun _ _ _ h => Contractive.distLater_dist (Dist.distLater h)" }, { "name": "Iris.OFE._inst_Ξ²", "content": "instance [OFE Ξ±] [OFE Ξ²] {x : Ξ²} : Contractive (fun _ : Ξ± => x) where\n distLater_dist := fun _ => Dist.rfl" }, { "name": "Iris.OFE.Hom", "content": "@[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n f : Ξ± β†’ Ξ²\n ne : NonExpansive f" }, { "name": "Iris.OFE._inst_Ξ±", "content": "instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -n> Ξ²) : NonExpansive f := f.ne" }, { "name": "Iris.OFE.ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "Iris.OFE._inst_Ξ±", "content": "instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -c> Ξ²) : Contractive f := f.contractive" }, { "name": "Iris.OFE._inst_OFE", "content": "instance : OFE Unit where\n Equiv _ _ := True\n Dist _ _ _ := True\n dist_eqv := ⟨fun _ => ⟨⟩, id, fun _ => id⟩\n equiv_dist := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] : OFE (ULift Ξ±) where\n Equiv x y := x.down ≑ y.down\n Dist n x y := x.down ≑{n}≑ y.down\n dist_eqv := InvImage.equivalence dist_eqv\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] : OFE (Option Ξ±) where\n Equiv := Option.Forallβ‚‚ Equiv\n Dist n := Option.Forallβ‚‚ (Dist n)\n dist_eqv := Option.Forallβ‚‚.equivalence dist_eqv\n equiv_dist {x y} := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE.Discrete Ξ±] : OFE.Discrete (Option Ξ±) where\n discrete_0 {mx my} e :=\n match mx, my with\n | none, none => e\n | none, some _ => e\n | some _, none => e\n | some x, some y => show x ≑ y from discrete_0 e" }, { "name": "Iris.OFE.OFE", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Iris.OFE.Option", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_Ξ±", "content": "instance [OFEFun (Ξ² : Ξ± β†’ _)] : OFE ((x : Ξ±) β†’ Ξ² x) where\n Equiv f g := βˆ€ x, f x ≑ g x\n Dist n f g := βˆ€ x, f x ≑{n}≑ g x\n dist_eqv := {\n refl _ _ := dist_eqv.refl _\n symm h _ := dist_eqv.symm (h _)\n trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _)\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -n> Ξ²) where\n Equiv f g := f.f ≑ g.f\n Dist n f g := f.f ≑{n}≑ g.f\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -c> Ξ²) where\n Equiv f g := Equiv f.toHom g.toHom\n Dist n f g := Dist n f.toHom g.toHom\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± Γ— Ξ²) where\n Equiv a b := a.1 ≑ b.1 ∧ a.2 ≑ b.2\n Dist n a b := a.1 ≑{n}≑ b.1 ∧ a.2 ≑{n}≑ b.2\n dist_eqv := {\n refl _ := ⟨dist_eqv.refl _, dist_eqv.refl _⟩\n symm h := ⟨dist_eqv.symm h.1, dist_eqv.symm h.2⟩\n trans h1 h2 := ⟨dist_eqv.trans h1.1 h2.1, dist_eqv.trans h1.2 h2.2⟩\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "Iris.OFE.Iso", "content": "@[ext] structure Iso (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n hom : Ξ± -n> Ξ²\n inv : Ξ² -n> Ξ±\n hom_inv : hom (inv x) ≑ x\n inv_hom : inv (hom x) ≑ x" }, { "name": "Iris.OFE._inst_Iso", "content": "instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.hom := iso.hom.ne" }, { "name": "Iris.OFE._inst_Iso", "content": "instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.inv := iso.inv.ne" }, { "name": "Iris.OFE.Iso.symm", "content": "def Iso.symm [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : Iso Ξ² Ξ± where\n hom := iso.inv\n inv := iso.hom\n hom_inv := by admit /- proof elided -/" }, { "name": "Iris.Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "Iris.IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Iris.LeibnizO", "content": "@[ext] structure LeibnizO (Ξ± : Type _) where\n car : Ξ±" }, { "name": "Iris.optionChain", "content": "def optionChain (c : Chain (Option Ξ±)) (x : Ξ±) : Chain Ξ± :=" }, { "name": "Iris.isCOFE_option", "content": "instance isCOFE_option [IsCOFE Ξ±] : IsCOFE (Option Ξ±) where\n compl c := (c 0).map fun x => IsCOFE.compl (optionChain c x)\n conv_compl {n} c := by admit /- proof elided -/" }, { "name": "Iris.LimitPreserving", "content": "def LimitPreserving [COFE Ξ±] (P : Ξ± β†’ Prop) : Prop :=\n βˆ€ (c : Chain Ξ±), (βˆ€ n, P (c n)) β†’ P (COFE.compl c)" }, { "name": "Iris.Fixpoint.chain", "content": "def Fixpoint.chain [OFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Chain Ξ± where\n chain n := Nat.repeat f (n + 1) default\n cauchy {n} := by admit /- proof elided -/" }, { "name": "Iris.fixpoint", "content": "def fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Ξ± :=\n COFE.compl <| Fixpoint.chain f\n\nnonrec abbrev OFE.ContractiveHom.fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) : Ξ± := fixpoint f.f" }, { "name": "Iris.OFE", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" } ]
[ { "name": "Iris.OFE.Dist.lt", "content": "theorem Dist.lt [OFE Ξ±] {m n} {x y : Ξ±} : x ≑{n}≑ y β†’ m < n β†’ x ≑{m}≑ y" }, { "name": "Iris.OFE.Dist.le", "content": "theorem Dist.le [OFE Ξ±] {m n} {x y : Ξ±} (h : x ≑{n}≑ y) (h' : m ≀ n) : x ≑{m}≑ y" }, { "name": "Iris.OFE.Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "Iris.OFE.Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Iris.OFE.Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "Iris.OFE.equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Iris.OFE.Equiv.symm", "content": "@[symm] theorem Equiv.symm [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ x" }, { "name": "Iris.OFE.Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "Iris.OFE.Equiv.dist", "content": "theorem Equiv.dist [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ x ≑{n}≑ y" }, { "name": "Iris.OFE.DistLater.symm", "content": "@[symm] theorem DistLater.symm [OFE Ξ±] {n} {x : Ξ±} (h : DistLater n x y) : DistLater n y x" }, { "name": "Iris.OFE.DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" }, { "name": "Iris.OFE.distLater_zero", "content": "@[simp] theorem distLater_zero [OFE Ξ±] {x y : Ξ±} : DistLater 0 x y" }, { "name": "Iris.OFE.distLater_succ", "content": "theorem distLater_succ [OFE Ξ±] {n} {x y : Ξ±} : DistLater n.succ x y ↔ x ≑{n}≑ y" }, { "name": "Iris.OFE.Contractive.zero", "content": "@[simp] theorem Contractive.zero [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] {x y} :\n f x ≑{0}≑ f y" }, { "name": "Iris.OFE.Contractive.succ", "content": "theorem Contractive.succ [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] {n x y}\n (h : x ≑{n}≑ y) : f x ≑{n.succ}≑ f y" }, { "name": "Iris.fixpoint_unfold", "content": "theorem fixpoint_unfold [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) :\n fixpoint f ≑ f (fixpoint f)" }, { "name": "Iris.fixpoint_unique", "content": "theorem fixpoint_unique [COFE Ξ±] [Inhabited Ξ±] {f : Ξ± -c> Ξ±} {x : Ξ±} (H : x ≑ f x) :\n x ≑ fixpoint f" } ]
namespace Iris class OFE (Ξ± : Type _) where Equiv : Ξ± β†’ Ξ± β†’ Prop Dist : Nat β†’ Ξ± β†’ Ξ± β†’ Prop dist_eqv : Equivalence (Dist n) equiv_dist : Equiv x y ↔ βˆ€ n, Dist n x y dist_lt : Dist n x y β†’ m < n β†’ Dist m x y open OFE scoped infix:40 " ≑ " => OFE.Equiv scoped notation:40 x " ≑{" n "}≑ " y:41 => OFE.Dist n x y namespace OFE class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚ instance id_ne [OFE Ξ±] : NonExpansive (@id Ξ±) := ⟨fun _ _ _ h => h⟩ class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚ def DistLater [OFE Ξ±] (n : Nat) (x y : Ξ±) : Prop := βˆ€ m, m < n β†’ x ≑{m}≑ y class Contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where distLater_dist : DistLater n x y β†’ f x ≑{n}≑ f y instance ne_of_contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] : NonExpansive f where ne := fun _ _ _ h => Contractive.distLater_dist (Dist.distLater h) instance [OFE Ξ±] [OFE Ξ²] {x : Ξ²} : Contractive (fun _ : Ξ± => x) where distLater_dist := fun _ => Dist.rfl @[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where f : Ξ± β†’ Ξ² ne : NonExpansive f @[inherit_doc] infixr:25 " -n> " => Hom instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -n> Ξ²) : NonExpansive f := f.ne @[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where [contractive : Contractive f] ne := ne_of_contractive f infixr:25 " -c> " => ContractiveHom instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -c> Ξ²) : Contractive f := f.contractive instance : OFE Unit where Equiv _ _ := True Dist _ _ _ := True dist_eqv := ⟨fun _ => ⟨⟩, id, fun _ => id⟩ equiv_dist := by admit /- proof elided -/ instance [OFE Ξ±] : OFE (ULift Ξ±) where Equiv x y := x.down ≑ y.down Dist n x y := x.down ≑{n}≑ y.down dist_eqv := InvImage.equivalence dist_eqv equiv_dist := equiv_dist dist_lt := dist_lt instance [OFE Ξ±] : OFE (Option Ξ±) where Equiv := Option.Forallβ‚‚ Equiv Dist n := Option.Forallβ‚‚ (Dist n) dist_eqv := Option.Forallβ‚‚.equivalence dist_eqv equiv_dist {x y} := by admit /- proof elided -/ instance [OFE Ξ±] [OFE.Discrete Ξ±] : OFE.Discrete (Option Ξ±) where discrete_0 {mx my} e := match mx, my with | none, none => e | none, some _ => e | some _, none => e | some x, some y => show x ≑ y from discrete_0 e instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩ instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] : NonExpansiveβ‚‚ (Option.merge op) where ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/ instance [OFEFun (Ξ² : Ξ± β†’ _)] : OFE ((x : Ξ±) β†’ Ξ² x) where Equiv f g := βˆ€ x, f x ≑ g x Dist n f g := βˆ€ x, f x ≑{n}≑ g x dist_eqv := { refl _ _ := dist_eqv.refl _ symm h _ := dist_eqv.symm (h _) trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _) } equiv_dist {_ _} := by admit /- proof elided -/ instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -n> Ξ²) where Equiv f g := f.f ≑ g.f Dist n f g := f.f ≑{n}≑ g.f dist_eqv := { refl _ := dist_eqv.refl _ symm h := dist_eqv.symm h trans h1 h2 := dist_eqv.trans h1 h2 } equiv_dist := equiv_dist dist_lt := dist_lt instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -c> Ξ²) where Equiv f g := Equiv f.toHom g.toHom Dist n f g := Dist n f.toHom g.toHom dist_eqv := { refl _ := dist_eqv.refl _ symm h := dist_eqv.symm h trans h1 h2 := dist_eqv.trans h1 h2 } equiv_dist := equiv_dist dist_lt := dist_lt instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± Γ— Ξ²) where Equiv a b := a.1 ≑ b.1 ∧ a.2 ≑ b.2 Dist n a b := a.1 ≑{n}≑ b.1 ∧ a.2 ≑{n}≑ b.2 dist_eqv := { refl _ := ⟨dist_eqv.refl _, dist_eqv.refl _⟩ symm h := ⟨dist_eqv.symm h.1, dist_eqv.symm h.2⟩ trans h1 h2 := ⟨dist_eqv.trans h1.1 h2.1, dist_eqv.trans h1.2 h2.2⟩ } equiv_dist {_ _} := by admit /- proof elided -/ @[ext] structure Iso (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where hom : Ξ± -n> Ξ² inv : Ξ² -n> Ξ± hom_inv : hom (inv x) ≑ x inv_hom : inv (hom x) ≑ x instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.hom := iso.hom.ne instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.inv := iso.inv.ne def Iso.symm [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : Iso Ξ² Ξ± where hom := iso.inv inv := iso.hom hom_inv := by admit /- proof elided -/ end OFE structure Chain (Ξ± : Type _) [OFE Ξ±] where chain : Nat β†’ Ξ± cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n namespace Chain end Chain class IsCOFE (Ξ± : Type _) [OFE Ξ±] where compl : Chain Ξ± β†’ Ξ± conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n namespace COFE end COFE @[ext] structure LeibnizO (Ξ± : Type _) where car : Ξ± section DiscreteFunOF open COFE end DiscreteFunOF section Option variable [OFE Ξ±] def optionChain (c : Chain (Option Ξ±)) (x : Ξ±) : Chain Ξ± := instance isCOFE_option [IsCOFE Ξ±] : IsCOFE (Option Ξ±) where compl c := (c 0).map fun x => IsCOFE.compl (optionChain c x) conv_compl {n} c := by admit /- proof elided -/ end Option section OptionOF open COFE variable (F : OFunctorPre) end OptionOF section Fixpoint def LimitPreserving [COFE Ξ±] (P : Ξ± β†’ Prop) : Prop := βˆ€ (c : Chain Ξ±), (βˆ€ n, P (c n)) β†’ P (COFE.compl c) def Fixpoint.chain [OFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Chain Ξ± where chain n := Nat.repeat f (n + 1) default cauchy {n} := by admit /- proof elided -/ def fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Ξ± := COFE.compl <| Fixpoint.chain f nonrec abbrev OFE.ContractiveHom.fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) : Ξ± := fixpoint f.f instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] : NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where ne n f1 f2 H := by admit /- proof elided -/
@[elab_as_elim] theorem OFE.ContractiveHom.fixpoint_ind [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) (P : Ξ± β†’ Prop) (HProper : βˆ€ A B : Ξ±, A ≑ B β†’ P A β†’ P B) (x : Ξ±) (Hbase : P x) (Hind : βˆ€ x, P x β†’ P (f x)) (Hlim : LimitPreserving P) : P f.fixpoint :=
:= by let chain : Chain α := by refine ⟨fun i => Nat.repeat f (i + 1) x, fun {n i} H => ?_⟩ induction n generalizing i with | zero => simp [Nat.repeat] | succ _ IH => cases i <;> simp at H exact Contractive.succ _ <| IH H refine HProper _ _ (fixpoint_unique (x := COFE.compl chain) ?_) ?_ · refine equiv_dist.mpr fun n => ?_ apply COFE.conv_compl.trans refine .trans ?_ (f.ne.ne COFE.conv_compl).symm induction n · exact Contractive.zero f.f · rename_i IH; apply Contractive.succ _ IH · apply Hlim; intro n induction n with | zero => exact Hind (Nat.repeat f.f 0 x) Hbase | succ _ IH => apply Hind (Nat.repeat f.f _ x) IH
5
47
true
Framework
223
Iris.BI.wand_iff_exists_persistently
theorem wand_iff_exists_persistently [BI PROP] [BIAffine PROP] {P Q : PROP} : (P -βˆ— Q) ⊣⊒ βˆƒ R, R βˆ— <pers> (P βˆ— R β†’ Q)
iris-lean
src/Iris/BI/DerivedLaws.lean
[ "import Iris.BI.Extensions", "import Iris.Std.TC", "import Iris.Std.Classes", "import Iris.BI.BI", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import Iris.BI.Classes", "import Iris.Std.Rewrite" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term\n\nsyntax:max \"<affine> \" term:40 : term\n\nsyntax:max \"β–‘ \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "BIAffine", "content": "class BIAffine (PROP : Type _) [BI PROP] where\n affine (P : PROP) : Affine P" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "Absorbing", "content": "class Absorbing [BI PROP] (P : PROP) where\n absorbing : <absorb> P ⊒ P" }, { "name": "inductive", "content": "class inductive TCOr (T U : Sort _)\n | l [t : T] : TCOr T U\n | r [u : U] : TCOr T U" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" } ]
[]
[ { "name": "Iris.BI.and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.imp_elim'", "content": "theorem imp_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P β†’ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.imp_elim_r", "content": "theorem imp_elim_r [BI PROP] {P Q : PROP} : P ∧ (P β†’ Q) ⊒ Q" }, { "name": "Iris.BI.true_intro", "content": "theorem true_intro [BI PROP] {P : PROP} : P ⊒ True" }, { "name": "Iris.BI.and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "Iris.BI.and_mono_r", "content": "theorem and_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P ∧ Q ⊒ P ∧ Q'" }, { "name": "Iris.BI.exists_intro", "content": "theorem exists_intro [BI PROP] {Ξ¨ : Ξ± β†’ PROP} (a : Ξ±) : Ξ¨ a ⊒ βˆƒ a, Ξ¨ a" }, { "name": "Iris.BI.exists_elim", "content": "theorem exists_elim [BI PROP] {Ξ¦ : Ξ± β†’ PROP} {Q : PROP} (h : βˆ€ a, Ξ¦ a ⊒ Q) : (βˆƒ a, Ξ¦ a) ⊒ Q" }, { "name": "Iris.BI.sep_mono_l", "content": "theorem sep_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P βˆ— Q ⊒ P' βˆ— Q" }, { "name": "Iris.BI.sep_mono_r", "content": "theorem sep_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P βˆ— Q ⊒ P βˆ— Q'" }, { "name": "Iris.BI.sep_congr", "content": "@[rw_mono_rule]\ntheorem sep_congr [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊣⊒ Q) (h2 : P' ⊣⊒ Q') :\n (P βˆ— P') ⊣⊒ (Q βˆ— Q')" }, { "name": "Iris.BI.sep_congr_l", "content": "theorem sep_congr_l [BI PROP] {P P' Q : PROP} (h : P ⊣⊒ P') : P βˆ— Q ⊣⊒ P' βˆ— Q" }, { "name": "Iris.BI.sep_congr_r", "content": "theorem sep_congr_r [BI PROP] {P Q Q' : PROP} (h : Q ⊣⊒ Q') : P βˆ— Q ⊣⊒ P βˆ— Q'" }, { "name": "Iris.BI.sep_comm", "content": "theorem sep_comm [BI PROP] {P Q : PROP} : P βˆ— Q ⊣⊒ Q βˆ— P" }, { "name": "Iris.BI.sep_assoc", "content": "theorem sep_assoc [BI PROP] {P Q R : PROP} : (P βˆ— Q) βˆ— R ⊣⊒ P βˆ— Q βˆ— R" }, { "name": "Iris.BI.sep_emp", "content": "theorem sep_emp [BI PROP] {P : PROP} : P βˆ— emp ⊣⊒ P" }, { "name": "Iris.BI.true_sep_2", "content": "theorem true_sep_2 [BI PROP] {P : PROP} : P ⊒ True βˆ— P" }, { "name": "Iris.BI.wand_intro'", "content": "theorem wand_intro' [BI PROP] {P Q R : PROP} (h : Q βˆ— P ⊒ R) : P ⊒ Q -βˆ— R" }, { "name": "Iris.BI.wand_elim'", "content": "theorem wand_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P -βˆ— R) : P βˆ— Q ⊒ R" }, { "name": "Iris.BI.wand_elim_r", "content": "theorem wand_elim_r [BI PROP] {P Q : PROP} : P βˆ— (P -βˆ— Q) ⊒ Q" }, { "name": "Iris.BI.absorbingly_intro", "content": "theorem absorbingly_intro [BI PROP] {P : PROP} : P ⊒ <absorb> P" }, { "name": "Iris.BI.absorbingly_pure", "content": "theorem absorbingly_pure {Ο† : Prop} [BI PROP] : <absorb> βŒœΟ†βŒ ⊣⊒ (βŒœΟ†βŒ : PROP)" }, { "name": "Iris.BI.sep_elim_l", "content": "theorem sep_elim_l [BI PROP] {P Q : PROP} : [TCOr (Affine Q) (Absorbing P)] β†’ P βˆ— Q ⊒ P\n | TCOr.l => (sep_mono_r affine).trans sep_emp.1\n | TCOr.r => (sep_mono_r true_intro).trans <| sep_comm.1.trans absorbing" }, { "name": "Iris.BI.sep_elim_r", "content": "theorem sep_elim_r [BI PROP] {P Q : PROP} [TCOr (Affine P) (Absorbing Q)] : P βˆ— Q ⊒ Q" }, { "name": "Iris.BI.sep_and", "content": "theorem sep_and [BI PROP] {P Q : PROP}\n [TCOr (Affine P) (Absorbing Q)] [TCOr (Affine Q) (Absorbing P)] : P βˆ— Q ⊒ P ∧ Q" }, { "name": "Iris.BI.true_sep", "content": "theorem true_sep [BI PROP] {P : PROP} [Absorbing P] : True βˆ— P ⊣⊒ P" }, { "name": "Iris.BI.sep_true", "content": "theorem sep_true [BI PROP] {P : PROP} [Absorbing P] : P βˆ— True ⊣⊒ P" }, { "name": "Iris.BI.persistently_absorb_r", "content": "theorem persistently_absorb_r [BI PROP] {P Q : PROP} : P βˆ— <pers> Q ⊒ <pers> Q" }, { "name": "Iris.BI.absorbingly_persistently", "content": "theorem absorbingly_persistently [BI PROP] {P : PROP} : <absorb> <pers> P ⊣⊒ <pers> P" }, { "name": "Iris.BI.persistently_emp_intro", "content": "theorem persistently_emp_intro [BI PROP] {P : PROP} : P ⊒ <pers> emp" }, { "name": "Iris.BI.persistently_emp", "content": "theorem persistently_emp [BI PROP] : <pers> (emp : PROP) ⊣⊒ True" }, { "name": "Iris.BI.persistently_true", "content": "theorem persistently_true [BI PROP] : <pers> (True : PROP) ⊣⊒ True" }, { "name": "Iris.BI.persistently_elim", "content": "theorem persistently_elim [BI PROP] {P : PROP} [Absorbing P] : <pers> P ⊒ P" }, { "name": "Iris.BI.persistently_idem", "content": "theorem persistently_idem [BI PROP] {P : PROP} : <pers> <pers> P ⊣⊒ <pers> P" }, { "name": "Iris.BI.persistently_intro'", "content": "theorem persistently_intro' [BI PROP] {P Q : PROP} (h : <pers> P ⊒ Q) : <pers> P ⊒ <pers> Q" }, { "name": "Iris.BI.persistently_pure", "content": "theorem persistently_pure {Ο† : Prop} [BI PROP] : <pers> βŒœΟ†βŒ ⊣⊒ (βŒœΟ†βŒ : PROP)" }, { "name": "Iris.BI.and_persistently_imp_sep", "content": "theorem and_persistently_imp_sep [BI PROP] {P Q : PROP} : P ∧ <pers> Q ⊒ P βˆ— <pers> Q" }, { "name": "Iris.BI.and_persistently_iff_sep", "content": "theorem and_persistently_iff_sep [BI PROP] [BIAffine PROP] {P Q : PROP} :\n P ∧ <pers> Q ⊣⊒ P βˆ— <pers> Q" } ]
import Iris.BI.Classes import Iris.BI.Extensions import Iris.BI.BI import Iris.Std.Classes import Iris.Std.Rewrite import Iris.Std.TC namespace Iris.BI open Iris.Std BI
theorem wand_iff_exists_persistently [BI PROP] [BIAffine PROP] {P Q : PROP} : (P -βˆ— Q) ⊣⊒ βˆƒ R, R βˆ— <pers> (P βˆ— R β†’ Q) :=
:= by constructor Β· refine (sep_true.2.trans ?_).trans (exists_intro iprop(P -βˆ— Q)) exact sep_mono_r <| persistently_pure.2.trans <| persistently_intro' <| imp_intro <| (and_mono persistently_pure.1 wand_elim_r).trans and_elim_r Β· exact exists_elim fun R => wand_intro' <| sep_assoc.2.trans <| and_persistently_iff_sep.2.trans <| (and_mono_r persistently_elim).trans imp_elim_r
6
89
false
Framework
224
Iris.COFE.OFunctor.Fix.Impl.Tower.embed_up
theorem Tower.embed_up (x : A F k) : Tower.embed (k+1) (up F k x) ≑ Tower.embed k x
iris-lean
src/Iris/Algebra/COFESolver.lean
[ "import Iris.Algebra.OFE" ]
[ { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "ULift", "module": "Init.Prelude" }, { "name": "Unit", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Inhabited.default", "module": "Init.Prelude" }, { "name": "k", "module": "QqTest.matching" }, { "name": "Nat.succ", "module": "Init.Prelude" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "Hom", "content": "@[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n f : Ξ± β†’ Ξ²\n ne : NonExpansive f" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "Hom.comp", "content": "protected def Hom.comp [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (g : Ξ² -n> Ξ³) (f : Ξ± -n> Ξ²) : Ξ± -n> Ξ³ where\n f := g.f ∘ f.f\n ne.1 _ _ _ h := g.ne.1 (f.ne.1 h)" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -n> \" => Hom" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -C> \" => Hom" } ]
[ { "name": "congrArg", "module": "Init.Prelude" }, { "name": "symm", "module": "Mathlib.Order.Defs.Unbundled" }, { "name": "Nat.add_assoc", "module": "Init.Data.Nat.Basic" }, { "name": "Nat.add_left_cancel", "module": "Init.Data.Nat.Basic" }, { "name": "Nat.add_left_cancel_iff", "module": "Init.Data.Nat.Lemmas" }, { "name": "Nat.add_right_comm", "module": "Init.Data.Nat.Basic" }, { "name": "Nat.le_antisymm", "module": "Init.Prelude" }, { "name": "Nat.le_of_succ_le", "module": "Init.Data.Nat.Basic" }, { "name": "Nat.not_lt", "module": "Init.Data.Nat.Basic" } ]
[ { "name": "exact", "content": "theorem exact [BI PROP] (Q : PROP) : Q ⊒ Q" } ]
[ { "name": "Iris.COFE.OFunctor.Fix.Impl.A'", "content": "def A' : Nat β†’ Ξ£ Ξ± : Type u, COFE Ξ±\n | 0 => ⟨ULift Unit, inferInstance⟩\n | n+1 => let ⟨A, _⟩ := A' n; ⟨F A A, inferInstance⟩" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.A", "content": "def A (n : Nat) : Type u := (A' F n).1" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.up", "content": "def up : βˆ€ k, A F k -n> A F (k+1)\n | 0 => ⟨fun _ => inh.default, ⟨fun _ _ _ _ => .rfl⟩⟩\n | k+1 => map (down k) (up k)" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.down", "content": "def down : βˆ€ k, A F (k+1) -n> A F k\n | 0 => ⟨fun _ => ⟨()⟩, ⟨fun _ _ _ _ => .rfl⟩⟩\n | k+1 => map (up k) (down k)" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.Tower", "content": "@[ext] structure Tower : Type u where\n val k : A F k\n protected down {k} : down F k (val (k+1)) ≑ val k" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.upN", "content": "def upN {k} : βˆ€ n, A F k -n> A F (k + n)\n | 0 => .id\n | n+1 => (up F (k + n)).comp (upN n)" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.downN", "content": "def downN {k} : βˆ€ n, A F (k + n) -n> A F k\n | 0 => .id\n | n+1 => (downN n).comp (down F (k + n))" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.eqToHom", "content": "def eqToHom (e : i = k) : A F i -n> A F k := e β–Έ .id" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.embed", "content": "def embed : A F k -n> A F i :=\n if h : k ≀ i then (eqToHom (Nat.add_sub_cancel' h)).comp (upN ..)\n else (downN ..).comp (eqToHom (Nat.add_sub_cancel' (Nat.le_of_not_ge h)).symm)" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.Tower.embed", "content": "protected def Tower.embed (k) : A F k -n> Tower F :=" } ]
[ { "name": "Iris.COFE.OFunctor.Fix.Impl.down_up", "content": "theorem down_up : βˆ€ {k} x, down F k (up F k x) ≑ x\n | 0, ⟨()⟩ => .rfl\n | _+1, _ => (map_comp ..).symm.trans <|\n (map_ne.eqv down_up down_up _).trans (map_id _)" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.eqToHom_up", "content": "theorem eqToHom_up {k k'} {x : A F k} (e : k = k') :\n eqToHom (congrArg Nat.succ e) (up F k x) = up F k' (eqToHom e x)" } ]
import Iris.Algebra.OFE namespace Iris.COFE.OFunctor open OFE variable {F : βˆ€ Ξ± Ξ² [OFE Ξ±] [OFE Ξ²], Type u} [OFunctorContractive F] variable [βˆ€ Ξ± [COFE Ξ±], IsCOFE (F Ξ± Ξ±)] variable [inh : Inhabited (F (ULift Unit) (ULift Unit))] namespace Fix.Impl variable (F) in def A' : Nat β†’ Ξ£ Ξ± : Type u, COFE Ξ± | 0 => ⟨ULift Unit, inferInstance⟩ | n+1 => let ⟨A, _⟩ := A' n; ⟨F A A, inferInstance⟩ variable (F) in def A (n : Nat) : Type u := (A' F n).1 variable (F) in def up : βˆ€ k, A F k -n> A F (k+1) | 0 => ⟨fun _ => inh.default, ⟨fun _ _ _ _ => .rfl⟩⟩ | k+1 => map (down k) (up k) def down : βˆ€ k, A F (k+1) -n> A F k | 0 => ⟨fun _ => ⟨()⟩, ⟨fun _ _ _ _ => .rfl⟩⟩ | k+1 => map (up k) (down k) end open OFunctorContractive in exact match k with | 0 => map_contractive.zero (x := (_, _)) (y := (_, _)) _ _ | k+1 => map_contractive.succ (x := (_, _)) (y := (_, _)) _ ⟨up_down, up_down⟩ _ variable (F) in @[ext] structure Tower : Type u where val k : A F k protected down {k} : down F k (val (k+1)) ≑ val k variable (F) in def upN {k} : βˆ€ n, A F k -n> A F (k + n) | 0 => .id | n+1 => (up F (k + n)).comp (upN n) variable (F) in def downN {k} : βˆ€ n, A F (k + n) -n> A F k | 0 => .id | n+1 => (downN n).comp (down F (k + n)) def eqToHom (e : i = k) : A F i -n> A F k := e β–Έ .id def embed : A F k -n> A F i := if h : k ≀ i then (eqToHom (Nat.add_sub_cancel' h)).comp (upN ..) else (downN ..).comp (eqToHom (Nat.add_sub_cancel' (Nat.le_of_not_ge h)).symm) protected def Tower.embed (k) : A F k -n> Tower F :=
theorem Tower.embed_up (x : A F k) : Tower.embed (k+1) (up F k x) ≑ Tower.embed k x :=
:= by refine equiv_dist.2 fun n i => ?_ dsimp [Tower.embed, embed]; split <;> rename_i h₁ Β· simp [Nat.le_of_succ_le h₁] suffices βˆ€ a b (e₁ : k + 1 + a = i) (eβ‚‚ : k+b = i), eqToHom e₁ (upN F a (up F k x)) = eqToHom eβ‚‚ (upN F b x) from this .. β–Έ .rfl rintro a b eq rfl rw [Nat.add_right_comm, Nat.add_assoc, Nat.add_left_cancel_iff] at eq; subst b show _ = up F (k + a) (upN F a x); clear h₁ induction a with | zero => rfl | succ a ih => dsimp [upN, Hom.comp] rw [eqToHom_up (by omega : k + 1 + a = k + (a + 1))]; congr 1; apply ih Β· split <;> rename_i hβ‚‚ Β· cases Nat.le_antisymm hβ‚‚ (Nat.not_lt.1 h₁) have {a b} {e₁ : k+1 = k+a} {eβ‚‚ : k+b = k+0} : downN F a (eqToHom e₁ (up F k x)) ≑{n}≑ eqToHom eβ‚‚ (upN F b x) := by cases Nat.add_left_cancel e₁; cases Nat.add_left_cancel eβ‚‚ exact (down_up ..).dist exact this Β· dsimp [Hom.comp] suffices βˆ€ a b (e₁ : k + 1 = i + a) (eβ‚‚ : k = i + b), downN F a (eqToHom e₁ (up F k x)) ≑{n}≑ downN F b (eqToHom eβ‚‚ x) from this .. rintro a b eq rfl; cases Nat.add_left_cancel (m := b+1) eq exact (downN ..).ne.1 (down_up x).dist
8
43
false
Framework
225
Iris.not_add_le_self
theorem not_add_le_self {a b : Ξ±} : Β¬ a + b ≀ a
iris-lean
src/Iris/Algebra/Frac.lean
[ "import Iris.Algebra.CMRA", "import Iris.Algebra.OFE" ]
[ { "name": "structure BitVec (w : Nat) where", "module": "" }, { "name": "/-- Construct a `BitVec w` from a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "ofFin ::", "module": "" }, { "name": "/-- Interpret a bitvector as a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "toFin : Fin (hPow 2 w)", "module": "" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "mt", "module": "Init.Core" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Iris.NumericFraction", "content": "class NumericFraction (Ξ± : Type _) extends One Ξ±, Add Ξ±, LE Ξ±, LT Ξ± where\n add_comm : βˆ€ a b : Ξ±, a + b = b + a\n add_assoc : βˆ€ a b c : Ξ±, a + (b + c) = (a + b) + c\n add_left_cancel : βˆ€ {a b c : Ξ±}, a + b = a + c β†’ b = c\n le_def : βˆ€ {a b : Ξ±}, a ≀ b ↔ a = b ∨ a < b\n lt_def : βˆ€ {a b : Ξ±}, a < b ↔ βˆƒ c : Ξ±, a + c = b\n lt_irrefl : βˆ€ {a : Ξ±}, Β¬a < a" } ]
[ { "name": "Iris.add_ne_self", "content": "theorem add_ne_self {a b : Ξ±} : a + b β‰  a" }, { "name": "Iris.not_add_lt_self", "content": "theorem not_add_lt_self {a b : Ξ±} : Β¬a + b < a" } ]
import Iris.Algebra.CMRA import Iris.Algebra.OFE namespace Iris namespace Fraction variable [Fraction Ξ±] end Fraction open Fraction OFE CMRA section NumericFraction class NumericFraction (Ξ± : Type _) extends One Ξ±, Add Ξ±, LE Ξ±, LT Ξ± where add_comm : βˆ€ a b : Ξ±, a + b = b + a add_assoc : βˆ€ a b c : Ξ±, a + (b + c) = (a + b) + c add_left_cancel : βˆ€ {a b c : Ξ±}, a + b = a + c β†’ b = c le_def : βˆ€ {a b : Ξ±}, a ≀ b ↔ a = b ∨ a < b lt_def : βˆ€ {a b : Ξ±}, a < b ↔ βˆƒ c : Ξ±, a + c = b lt_irrefl : βˆ€ {a : Ξ±}, Β¬a < a variable {Ξ±} [NumericFraction Ξ±] open NumericFraction
theorem not_add_le_self {a b : Ξ±} : Β¬ a + b ≀ a :=
:= fun H => by obtain H | H := le_def.mp H Β· exact add_ne_self H Β· exact not_add_lt_self H
3
4
false
Framework
226
Iris.BI.imp_iff_exists_persistently
theorem imp_iff_exists_persistently [BI PROP] [BIAffine PROP] {P Q : PROP} : (P β†’ Q) ⊣⊒ βˆƒ R, R ∧ <pers> (P ∧ R -βˆ— Q)
iris-lean
src/Iris/BI/DerivedLaws.lean
[ "import Iris.BI.Extensions", "import Iris.Std.TC", "import Iris.Std.Classes", "import Iris.BI.BI", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import Iris.BI.Classes", "import Iris.Std.Rewrite" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term\n\nsyntax:max \"<affine> \" term:40 : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term\n\nsyntax:max \"β–‘ \" term:40 : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "BIAffine", "content": "class BIAffine (PROP : Type _) [BI PROP] where\n affine (P : PROP) : Affine P" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" } ]
[]
[ { "name": "Iris.BI.and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_symm", "content": "theorem and_symm [BI PROP] {P Q : PROP} : P ∧ Q ⊒ Q ∧ P" }, { "name": "Iris.BI.imp_intro'", "content": "theorem imp_intro' [BI PROP] {P Q R : PROP} (h : Q ∧ P ⊒ R) : P ⊒ Q β†’ R" }, { "name": "Iris.BI.imp_elim'", "content": "theorem imp_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P β†’ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.imp_elim_r", "content": "theorem imp_elim_r [BI PROP] {P Q : PROP} : P ∧ (P β†’ Q) ⊒ Q" }, { "name": "Iris.BI.true_intro", "content": "theorem true_intro [BI PROP] {P : PROP} : P ⊒ True" }, { "name": "Iris.BI.and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "Iris.BI.and_mono_l", "content": "theorem and_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P ∧ Q ⊒ P' ∧ Q" }, { "name": "Iris.BI.and_mono_r", "content": "theorem and_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P ∧ Q ⊒ P ∧ Q'" }, { "name": "Iris.BI.exists_intro", "content": "theorem exists_intro [BI PROP] {Ξ¨ : Ξ± β†’ PROP} (a : Ξ±) : Ξ¨ a ⊒ βˆƒ a, Ξ¨ a" }, { "name": "Iris.BI.exists_elim", "content": "theorem exists_elim [BI PROP] {Ξ¦ : Ξ± β†’ PROP} {Q : PROP} (h : βˆ€ a, Ξ¦ a ⊒ Q) : (βˆƒ a, Ξ¦ a) ⊒ Q" }, { "name": "Iris.BI.and_comm", "content": "theorem and_comm [BI PROP] {P Q : PROP} : P ∧ Q ⊣⊒ Q ∧ P" }, { "name": "Iris.BI.true_and", "content": "theorem true_and [BI PROP] {P : PROP} : True ∧ P ⊣⊒ P" }, { "name": "Iris.BI.and_true", "content": "theorem and_true [BI PROP] {P : PROP} : P ∧ True ⊣⊒ P" }, { "name": "Iris.BI.and_assoc", "content": "theorem and_assoc [BI PROP] {P Q R : PROP} : (P ∧ Q) ∧ R ⊣⊒ P ∧ Q ∧ R" }, { "name": "Iris.BI.sep_mono_l", "content": "theorem sep_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P βˆ— Q ⊒ P' βˆ— Q" }, { "name": "Iris.BI.sep_mono_r", "content": "theorem sep_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P βˆ— Q ⊒ P βˆ— Q'" }, { "name": "Iris.BI.sep_comm", "content": "theorem sep_comm [BI PROP] {P Q : PROP} : P βˆ— Q ⊣⊒ Q βˆ— P" }, { "name": "Iris.BI.sep_emp", "content": "theorem sep_emp [BI PROP] {P : PROP} : P βˆ— emp ⊣⊒ P" }, { "name": "Iris.BI.wand_elim'", "content": "theorem wand_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P -βˆ— R) : P βˆ— Q ⊒ R" }, { "name": "Iris.BI.wand_elim_r", "content": "theorem wand_elim_r [BI PROP] {P Q : PROP} : P βˆ— (P -βˆ— Q) ⊒ Q" }, { "name": "Iris.BI.affinely_elim", "content": "theorem affinely_elim [BI PROP] {P : PROP} : <affine> P ⊒ P" }, { "name": "Iris.BI.persistently_emp_intro", "content": "theorem persistently_emp_intro [BI PROP] {P : PROP} : P ⊒ <pers> emp" }, { "name": "Iris.BI.persistently_emp", "content": "theorem persistently_emp [BI PROP] : <pers> (emp : PROP) ⊣⊒ True" }, { "name": "Iris.BI.intuitionistically_elim", "content": "theorem intuitionistically_elim [BI PROP] {P : PROP} : β–‘ P ⊒ P" }, { "name": "Iris.BI.persistently_and_intuitionistically_sep_r", "content": "theorem persistently_and_intuitionistically_sep_r [BI PROP] {P Q : PROP} :\n P ∧ <pers> Q ⊣⊒ P βˆ— β–‘ Q" } ]
import Iris.BI.Classes import Iris.BI.Extensions import Iris.BI.BI import Iris.Std.Classes import Iris.Std.Rewrite import Iris.Std.TC namespace Iris.BI open Iris.Std BI
theorem imp_iff_exists_persistently [BI PROP] [BIAffine PROP] {P Q : PROP} : (P β†’ Q) ⊣⊒ βˆƒ R, R ∧ <pers> (P ∧ R -βˆ— Q) :=
:= by constructor Β· refine (and_true.2.trans ?_).trans (exists_intro iprop(P β†’ Q)) exact and_mono_r <| persistently_emp.2.trans <| persistently_mono <| wand_intro <| emp_sep.1.trans imp_elim_r Β· exact exists_elim fun R => imp_intro' <| and_assoc.2.trans <| persistently_and_intuitionistically_sep_r.1.trans <| (sep_mono_r intuitionistically_elim).trans wand_elim_r
5
75
false
Framework
227
Iris.COFE.OFunctor.Fix.Impl.downN_upN
theorem downN_upN {k} (x : A F k) : βˆ€ {i}, downN F i (upN F i x) ≑ x | 0 => .rfl | n+1 => ((downN F n).ne.eqv (down_up ..)).trans (downN_upN _)
iris-lean
src/Iris/Algebra/COFESolver.lean
[ "import Iris.Algebra.OFE" ]
[ { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "ULift", "module": "Init.Prelude" }, { "name": "Unit", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Inhabited.default", "module": "Init.Prelude" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "Hom", "content": "@[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n f : Ξ± β†’ Ξ²\n ne : NonExpansive f" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -n> \" => Hom" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -C> \" => Hom" } ]
[ { "name": "symm", "module": "Mathlib.Order.Defs.Unbundled" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Iris.COFE.OFunctor.Fix.Impl.A'", "content": "def A' : Nat β†’ Ξ£ Ξ± : Type u, COFE Ξ±\n | 0 => ⟨ULift Unit, inferInstance⟩\n | n+1 => let ⟨A, _⟩ := A' n; ⟨F A A, inferInstance⟩" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.A", "content": "def A (n : Nat) : Type u := (A' F n).1" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.up", "content": "def up : βˆ€ k, A F k -n> A F (k+1)\n | 0 => ⟨fun _ => inh.default, ⟨fun _ _ _ _ => .rfl⟩⟩\n | k+1 => map (down k) (up k)" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.down", "content": "def down : βˆ€ k, A F (k+1) -n> A F k\n | 0 => ⟨fun _ => ⟨()⟩, ⟨fun _ _ _ _ => .rfl⟩⟩\n | k+1 => map (up k) (down k)" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.upN", "content": "def upN {k} : βˆ€ n, A F k -n> A F (k + n)\n | 0 => .id\n | n+1 => (up F (k + n)).comp (upN n)" }, { "name": "Iris.COFE.OFunctor.Fix.Impl.downN", "content": "def downN {k} : βˆ€ n, A F (k + n) -n> A F k\n | 0 => .id\n | n+1 => (downN n).comp (down F (k + n))" } ]
[ { "name": "Iris.COFE.OFunctor.Fix.Impl.down_up", "content": "theorem down_up : βˆ€ {k} x, down F k (up F k x) ≑ x\n | 0, ⟨()⟩ => .rfl\n | _+1, _ => (map_comp ..).symm.trans <|\n (map_ne.eqv down_up down_up _).trans (map_id _)" } ]
import Iris.Algebra.OFE namespace Iris.COFE.OFunctor open OFE variable {F : βˆ€ Ξ± Ξ² [OFE Ξ±] [OFE Ξ²], Type u} [OFunctorContractive F] variable [βˆ€ Ξ± [COFE Ξ±], IsCOFE (F Ξ± Ξ±)] variable [inh : Inhabited (F (ULift Unit) (ULift Unit))] namespace Fix.Impl variable (F) in def A' : Nat β†’ Ξ£ Ξ± : Type u, COFE Ξ± | 0 => ⟨ULift Unit, inferInstance⟩ | n+1 => let ⟨A, _⟩ := A' n; ⟨F A A, inferInstance⟩ variable (F) in def A (n : Nat) : Type u := (A' F n).1 variable (F) in def up : βˆ€ k, A F k -n> A F (k+1) | 0 => ⟨fun _ => inh.default, ⟨fun _ _ _ _ => .rfl⟩⟩ | k+1 => map (down k) (up k) def down : βˆ€ k, A F (k+1) -n> A F k | 0 => ⟨fun _ => ⟨()⟩, ⟨fun _ _ _ _ => .rfl⟩⟩ | k+1 => map (up k) (down k) end open OFunctorContractive in exact match k with | 0 => map_contractive.zero (x := (_, _)) (y := (_, _)) _ _ | k+1 => map_contractive.succ (x := (_, _)) (y := (_, _)) _ ⟨up_down, up_down⟩ _ variable (F) in variable (F) in def upN {k} : βˆ€ n, A F k -n> A F (k + n) | 0 => .id | n+1 => (up F (k + n)).comp (upN n) variable (F) in def downN {k} : βˆ€ n, A F (k + n) -n> A F k | 0 => .id | n+1 => (downN n).comp (down F (k + n))
theorem downN_upN {k} (x : A F k) : βˆ€ {i}, downN F i (upN F i x) ≑ x :=
| 0 => .rfl | n+1 => ((downN F n).ne.eqv (down_up ..)).trans (downN_upN _)
8
27
false
Framework
228
Iris.BI.persistently_sep
theorem persistently_sep [BI PROP] [BIPositive PROP] {P Q : PROP} : <pers> (P βˆ— Q) ⊣⊒ <pers> P βˆ— <pers> Q
iris-lean
src/Iris/BI/DerivedLaws.lean
[ "import Iris.BI.Extensions", "import Iris.Std.TC", "import Iris.Std.Classes", "import Iris.BI.BI", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import Iris.BI.Classes", "import Iris.Std.Rewrite" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term\n\nsyntax:max \"<affine> \" term:40 : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term\n\nsyntax:max \"β–‘ \" term:40 : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "BIPositive", "content": "class BIPositive (PROP : Type _) [BI PROP] where\n affinely_sep_l {P Q : PROP} : <affine> (P βˆ— Q) ⊒ <affine> P βˆ— Q" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" } ]
[]
[ { "name": "Iris.BI.and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_symm", "content": "theorem and_symm [BI PROP] {P Q : PROP} : P ∧ Q ⊒ Q ∧ P" }, { "name": "Iris.BI.true_intro", "content": "theorem true_intro [BI PROP] {P : PROP} : P ⊒ True" }, { "name": "Iris.BI.and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "Iris.BI.and_mono_l", "content": "theorem and_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P ∧ Q ⊒ P' ∧ Q" }, { "name": "Iris.BI.and_mono_r", "content": "theorem and_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P ∧ Q ⊒ P ∧ Q'" }, { "name": "Iris.BI.and_congr", "content": "@[rw_mono_rule]\ntheorem and_congr [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊣⊒ Q) (h2 : P' ⊣⊒ Q') : P ∧ P' ⊣⊒ Q ∧ Q'" }, { "name": "Iris.BI.and_congr_l", "content": "theorem and_congr_l [BI PROP] {P P' Q : PROP} (h : P ⊣⊒ P') : P ∧ Q ⊣⊒ P' ∧ Q" }, { "name": "Iris.BI.and_self", "content": "theorem and_self [BI PROP] {P : PROP} : P ∧ P ⊣⊒ P" }, { "name": "Iris.BI.and_comm", "content": "theorem and_comm [BI PROP] {P Q : PROP} : P ∧ Q ⊣⊒ Q ∧ P" }, { "name": "Iris.BI.and_assoc", "content": "theorem and_assoc [BI PROP] {P Q R : PROP} : (P ∧ Q) ∧ R ⊣⊒ P ∧ Q ∧ R" }, { "name": "Iris.BI.sep_mono_l", "content": "theorem sep_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P βˆ— Q ⊒ P' βˆ— Q" }, { "name": "Iris.BI.sep_mono_r", "content": "theorem sep_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P βˆ— Q ⊒ P βˆ— Q'" }, { "name": "Iris.BI.sep_congr", "content": "@[rw_mono_rule]\ntheorem sep_congr [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊣⊒ Q) (h2 : P' ⊣⊒ Q') :\n (P βˆ— P') ⊣⊒ (Q βˆ— Q')" }, { "name": "Iris.BI.sep_congr_l", "content": "theorem sep_congr_l [BI PROP] {P P' Q : PROP} (h : P ⊣⊒ P') : P βˆ— Q ⊣⊒ P' βˆ— Q" }, { "name": "Iris.BI.sep_congr_r", "content": "theorem sep_congr_r [BI PROP] {P Q Q' : PROP} (h : Q ⊣⊒ Q') : P βˆ— Q ⊣⊒ P βˆ— Q'" }, { "name": "Iris.BI.sep_comm", "content": "theorem sep_comm [BI PROP] {P Q : PROP} : P βˆ— Q ⊣⊒ Q βˆ— P" }, { "name": "Iris.BI.sep_assoc", "content": "theorem sep_assoc [BI PROP] {P Q R : PROP} : (P βˆ— Q) βˆ— R ⊣⊒ P βˆ— Q βˆ— R" }, { "name": "Iris.BI.sep_emp", "content": "theorem sep_emp [BI PROP] {P : PROP} : P βˆ— emp ⊣⊒ P" }, { "name": "Iris.BI.true_sep_2", "content": "theorem true_sep_2 [BI PROP] {P : PROP} : P ⊒ True βˆ— P" }, { "name": "Iris.BI.affinely_elim_emp", "content": "theorem affinely_elim_emp [BI PROP] {P : PROP} : <affine> P ⊒ emp" }, { "name": "Iris.BI.affinely_elim", "content": "theorem affinely_elim [BI PROP] {P : PROP} : <affine> P ⊒ P" }, { "name": "Iris.BI.affinely_mono", "content": "@[rw_mono_rule]\ntheorem affinely_mono [BI PROP] {P Q : PROP} : (P ⊒ Q) β†’ <affine> P ⊒ <affine> Q" }, { "name": "Iris.BI.affinely_idem", "content": "theorem affinely_idem [BI PROP] {P : PROP} : <affine> <affine> P ⊣⊒ <affine> P" }, { "name": "Iris.BI.affinely_sep_2", "content": "theorem affinely_sep_2 [BI PROP] {P Q : PROP} : <affine> P βˆ— <affine> Q ⊒ <affine> (P βˆ— Q)" }, { "name": "Iris.BI.affinely_sep_r", "content": "theorem affinely_sep_r [BI PROP] [BIPositive PROP] {P Q : PROP} :\n <affine> (P βˆ— Q) ⊒ P βˆ— <affine> Q" }, { "name": "Iris.BI.affinely_sep", "content": "theorem affinely_sep [BI PROP] [BIPositive PROP] {P Q : PROP} :\n <affine> (P βˆ— Q) ⊣⊒ <affine> P βˆ— <affine> Q" }, { "name": "Iris.BI.absorbingly_intro", "content": "theorem absorbingly_intro [BI PROP] {P : PROP} : P ⊒ <absorb> P" }, { "name": "Iris.BI.persistently_absorb_r", "content": "theorem persistently_absorb_r [BI PROP] {P Q : PROP} : P βˆ— <pers> Q ⊒ <pers> Q" }, { "name": "Iris.BI.absorbingly_persistently", "content": "theorem absorbingly_persistently [BI PROP] {P : PROP} : <absorb> <pers> P ⊣⊒ <pers> P" }, { "name": "Iris.BI.persistently_and", "content": "theorem persistently_and [BI PROP] {P Q : PROP} : <pers> (P ∧ Q) ⊣⊒ <pers> P ∧ <pers> Q" }, { "name": "Iris.BI.persistently_emp_intro", "content": "theorem persistently_emp_intro [BI PROP] {P : PROP} : P ⊒ <pers> emp" }, { "name": "Iris.BI.persistently_affinely", "content": "theorem persistently_affinely [BI PROP] {P : PROP} : <pers> <affine> P ⊣⊒ <pers> P" }, { "name": "Iris.BI.persistently_and_sep_assoc", "content": "theorem persistently_and_sep_assoc [BI PROP] {P Q R : PROP} :\n <pers> P ∧ (Q βˆ— R) ⊣⊒ (<pers> P ∧ Q) βˆ— R" }, { "name": "Iris.BI.intuitionistically_elim", "content": "theorem intuitionistically_elim [BI PROP] {P : PROP} : β–‘ P ⊒ P" }, { "name": "Iris.BI.persistently_idem", "content": "theorem persistently_idem [BI PROP] {P : PROP} : <pers> <pers> P ⊣⊒ <pers> P" }, { "name": "Iris.BI.persistently_and_imp_sep", "content": "theorem persistently_and_imp_sep [BI PROP] {P Q : PROP} : <pers> P ∧ Q ⊒ <pers> P βˆ— Q" }, { "name": "Iris.BI.persistently_and_sep", "content": "theorem persistently_and_sep [BI PROP] {P Q : PROP} : <pers> (P ∧ Q) ⊒ <pers> (P βˆ— Q)" }, { "name": "Iris.BI.persistently_and_persistently_sep", "content": "theorem persistently_and_persistently_sep [BI PROP] {P Q : PROP} :\n <pers> P ∧ <pers> Q ⊣⊒ <pers> P βˆ— <pers> Q" }, { "name": "Iris.BI.persistently_sep_2", "content": "theorem persistently_sep_2 [BI PROP] {P Q : PROP} : <pers> P βˆ— <pers> Q ⊒ <pers> (P βˆ— Q)" } ]
import Iris.BI.Classes import Iris.BI.Extensions import Iris.BI.BI import Iris.Std.Classes import Iris.Std.Rewrite import Iris.Std.TC namespace Iris.BI open Iris.Std BI
theorem persistently_sep [BI PROP] [BIPositive PROP] {P Q : PROP} : <pers> (P βˆ— Q) ⊣⊒ <pers> P βˆ— <pers> Q :=
:= by refine ⟨persistently_affinely.2.trans ?_, persistently_sep_2⟩ refine persistently_mono affinely_sep.1 |>.trans ?_ |>.trans persistently_and_persistently_sep.1 exact and_intro (persistently_mono <| (sep_mono_r affinely_elim_emp).trans <| sep_emp.1.trans affinely_elim) (persistently_mono <| (sep_mono_l affinely_elim_emp).trans <| emp_sep.1.trans affinely_elim)
7
89
false
Framework
229
Iris.BI.loeb_wand_intuitionistically
theorem loeb_wand_intuitionistically [BI PROP] [BILoeb PROP] {P : PROP} : β–‘ (β–‘ β–· P -βˆ— P) ⊒ P
iris-lean
src/Iris/BI/DerivedLaws.lean
[ "import Iris.BI.Extensions", "import Iris.Std.TC", "import Iris.Std.Classes", "import Iris.BI.BI", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import Iris.BI.Classes", "import Iris.Std.Rewrite" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Function.const", "module": "Init.Prelude" } ]
[ { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term\n\nsyntax:max \"<affine> \" term:40 : term\n\nsyntax:max \"β–‘ \" term:40 : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "BILoeb", "content": "class BILoeb (PROP : Type _) [BI PROP] where\n loeb_weak {P : PROP} : (β–· P ⊒ P) β†’ True ⊒ P" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" } ]
[]
[ { "name": "Iris.BI.and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_symm", "content": "theorem and_symm [BI PROP] {P Q : PROP} : P ∧ Q ⊒ Q ∧ P" }, { "name": "Iris.BI.imp_intro'", "content": "theorem imp_intro' [BI PROP] {P Q R : PROP} (h : Q ∧ P ⊒ R) : P ⊒ Q β†’ R" }, { "name": "Iris.BI.imp_elim'", "content": "theorem imp_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P β†’ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.imp_elim_l", "content": "theorem imp_elim_l [BI PROP] {P Q : PROP} : (P β†’ Q) ∧ P ⊒ Q" }, { "name": "Iris.BI.imp_elim_r", "content": "theorem imp_elim_r [BI PROP] {P Q : PROP} : P ∧ (P β†’ Q) ⊒ Q" }, { "name": "Iris.BI.true_intro", "content": "theorem true_intro [BI PROP] {P : PROP} : P ⊒ True" }, { "name": "Iris.BI.and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "Iris.BI.and_mono_l", "content": "theorem and_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P ∧ Q ⊒ P' ∧ Q" }, { "name": "Iris.BI.and_mono_r", "content": "theorem and_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P ∧ Q ⊒ P ∧ Q'" }, { "name": "Iris.BI.and_congr", "content": "@[rw_mono_rule]\ntheorem and_congr [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊣⊒ Q) (h2 : P' ⊣⊒ Q') : P ∧ P' ⊣⊒ Q ∧ Q'" }, { "name": "Iris.BI.and_congr_r", "content": "theorem and_congr_r [BI PROP] {P Q Q' : PROP} (h : Q ⊣⊒ Q') : P ∧ Q ⊣⊒ P ∧ Q'" }, { "name": "Iris.BI.and_self", "content": "theorem and_self [BI PROP] {P : PROP} : P ∧ P ⊣⊒ P" }, { "name": "Iris.BI.and_comm", "content": "theorem and_comm [BI PROP] {P Q : PROP} : P ∧ Q ⊣⊒ Q ∧ P" }, { "name": "Iris.BI.and_assoc", "content": "theorem and_assoc [BI PROP] {P Q R : PROP} : (P ∧ Q) ∧ R ⊣⊒ P ∧ Q ∧ R" }, { "name": "Iris.BI.sep_mono_l", "content": "theorem sep_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P βˆ— Q ⊒ P' βˆ— Q" }, { "name": "Iris.BI.sep_comm", "content": "theorem sep_comm [BI PROP] {P Q : PROP} : P βˆ— Q ⊣⊒ Q βˆ— P" }, { "name": "Iris.BI.sep_emp", "content": "theorem sep_emp [BI PROP] {P : PROP} : P βˆ— emp ⊣⊒ P" }, { "name": "Iris.BI.true_sep_2", "content": "theorem true_sep_2 [BI PROP] {P : PROP} : P ⊒ True βˆ— P" }, { "name": "Iris.BI.wand_elim'", "content": "theorem wand_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P -βˆ— R) : P βˆ— Q ⊒ R" }, { "name": "Iris.BI.wand_elim_r", "content": "theorem wand_elim_r [BI PROP] {P Q : PROP} : P βˆ— (P -βˆ— Q) ⊒ Q" }, { "name": "Iris.BI.pure_elim", "content": "theorem pure_elim [BI PROP] (Ο† : Prop) {Q R : PROP} (h1 : Q ⊒ βŒœΟ†βŒ) (h2 : Ο† β†’ Q ⊒ R) : Q ⊒ R" }, { "name": "Iris.BI.pure_elim_l", "content": "theorem pure_elim_l [BI PROP] {Ο† : Prop} {Q R : PROP} (h : Ο† β†’ Q ⊒ R) : βŒœΟ†βŒ ∧ Q ⊒ R" }, { "name": "Iris.BI.pure_elim_r", "content": "theorem pure_elim_r [BI PROP] {Ο† : Prop} {Q R : PROP} (h : Ο† β†’ Q ⊒ R) : Q ∧ βŒœΟ†βŒ ⊒ R" }, { "name": "Iris.BI.affinely_congr", "content": "@[rw_mono_rule]\ntheorem affinely_congr [BI PROP] {P P' : PROP} (h : P ⊣⊒ P') :\n <affine> P ⊣⊒ <affine> P'" }, { "name": "Iris.BI.affinely_elim", "content": "theorem affinely_elim [BI PROP] {P : PROP} : <affine> P ⊒ P" }, { "name": "Iris.BI.affinely_mono", "content": "@[rw_mono_rule]\ntheorem affinely_mono [BI PROP] {P Q : PROP} : (P ⊒ Q) β†’ <affine> P ⊒ <affine> Q" }, { "name": "Iris.BI.absorbingly_intro", "content": "theorem absorbingly_intro [BI PROP] {P : PROP} : P ⊒ <absorb> P" }, { "name": "Iris.BI.persistently_absorb_r", "content": "theorem persistently_absorb_r [BI PROP] {P Q : PROP} : P βˆ— <pers> Q ⊒ <pers> Q" }, { "name": "Iris.BI.absorbingly_persistently", "content": "theorem absorbingly_persistently [BI PROP] {P : PROP} : <absorb> <pers> P ⊣⊒ <pers> P" }, { "name": "Iris.BI.persistently_and", "content": "theorem persistently_and [BI PROP] {P Q : PROP} : <pers> (P ∧ Q) ⊣⊒ <pers> P ∧ <pers> Q" }, { "name": "Iris.BI.persistently_emp_intro", "content": "theorem persistently_emp_intro [BI PROP] {P : PROP} : P ⊒ <pers> emp" }, { "name": "Iris.BI.persistently_affinely", "content": "theorem persistently_affinely [BI PROP] {P : PROP} : <pers> <affine> P ⊣⊒ <pers> P" }, { "name": "Iris.BI.intuitionistically_elim", "content": "theorem intuitionistically_elim [BI PROP] {P : PROP} : β–‘ P ⊒ P" }, { "name": "Iris.BI.persistently_idem", "content": "theorem persistently_idem [BI PROP] {P : PROP} : <pers> <pers> P ⊣⊒ <pers> P" }, { "name": "Iris.BI.intuitionistically_mono", "content": "@[rw_mono_rule]\ntheorem intuitionistically_mono [BI PROP] {P Q : PROP} (h : P ⊒ Q) : β–‘ P ⊒ β–‘ Q" }, { "name": "Iris.BI.intuitionistically_idem", "content": "theorem intuitionistically_idem [BI PROP] {P : PROP} : β–‘ β–‘ P ⊣⊒ β–‘ P" }, { "name": "Iris.BI.persistently_of_intuitionistically", "content": "theorem persistently_of_intuitionistically [BI PROP] {P : PROP} : β–‘ P ⊒ <pers> P" }, { "name": "Iris.BI.later_impl", "content": "theorem later_impl [BI PROP] {P Q : PROP} : β–· (P β†’ Q) ⊒ β–· P β†’ β–· Q" }, { "name": "Iris.BI.entails_impl_true", "content": "theorem entails_impl_true [BI PROP] {P Q : PROP} :\n (P ⊒ Q) ↔ iprop((True : PROP) ⊒ (P β†’ Q))" }, { "name": "Iris.BI.loeb", "content": "theorem loeb [BI PROP] [BILoeb PROP] {P : PROP} : (β–· P β†’ P) ⊒ P" } ]
import Iris.BI.Classes import Iris.BI.Extensions import Iris.BI.BI import Iris.Std.Classes import Iris.Std.Rewrite import Iris.Std.TC namespace Iris.BI open Iris.Std BI
theorem loeb_wand_intuitionistically [BI PROP] [BILoeb PROP] {P : PROP} : β–‘ (β–‘ β–· P -βˆ— P) ⊒ P :=
:= by refine .trans ?_ intuitionistically_elim refine .trans ?_ loeb refine imp_intro' ?_ refine (and_mono (later_mono persistently_of_intuitionistically) .rfl).trans ?_ refine (and_mono later_persistently.mp .rfl).trans ?_ refine persistently_and_intuitionistically_sep_l.mp.trans ?_ refine (sep_mono intuitionistically_idem.mpr .rfl).trans ?_ exact intuitionistically_sep_2.trans (intuitionistically_mono wand_elim_r)
6
91
false
Framework
230
Iris.BI.plainly_persistently_elim
theorem plainly_persistently_elim : β–  <pers> P ⊣⊒ β–  P
iris-lean
src/Iris/BI/Plainly.lean
[ "import Iris.Algebra", "import Iris.BI.DerivedLaws", "import src.Iris.Algebra.CMRA", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import src.Iris.BI.DerivedLaws", "import src/Iris/Instances/UPred/Instance.lean", "import Iris.BI.BI", "import Iris.BI.Classes" ]
[ { "name": "Lean.MonadQuotation", "module": "Init.Prelude" }, { "name": "Lean.MonadRef", "module": "Init.Prelude" }, { "name": "Monad", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" } ]
[ { "name": "syntax term:26 \" ==βˆ— \" term:25 : term", "content": "syntax term:26 \" ==βˆ— \" term:25 : term\n\nsyntax term \"={ \" term \" , \" term \" }=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }[ \" term \" ]β–·=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }β–·=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }[ \" term \" ]β–·^\" term \"=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }β–·^\" term \"=βˆ— \" term : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term" }, { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term\n\nsyntax \"β–  \" term:40 : term" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y\n\nsyntax:max \"<affine> \" term:40 : term\n\nsyntax:max \"β–‘ \" term:40 : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|==> $P)) => ``(BUpd.bupd iprop($P))\n | `(iprop($P ==βˆ— $Q)) => ``(BIBase.wand iprop($P) (BUpd.bupd iprop($Q)))\n\ndelab_rule BUpd.bupd\n | `($_ $P) => do ``(iprop(|==> $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 , $E2 }=> $P)) => ``(FUpd.fupd $E1 $E2 iprop($P))\n | `(iprop($P ={ $E1 , $E2 }=βˆ— $Q)) => ``(BIBase.wand iprop($P) (FUpd.fupd $E1 $E2 iprop($Q)))\n | `(iprop(|={ $E1 }=> $P)) => ``(FUpd.fupd $E1 $E1 iprop($P))\n | `(iprop($P ={ $E1 }=βˆ— $Q)) => ``(BIBase.wand iprop($P) (FUpd.fupd $E1 $E1 iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 }[ $E2 ]β–·=> $P)) => ``(iprop(|={$E1, $E2}=> β–· (|={ $E2, $E1 }=> iprop($P))))\n | `(iprop($P ={ $E1 }[ $E2 ]β–·=βˆ— $Q)) => ``(iprop(iprop($P) -βˆ— |={$E1}[$E2]β–·=> iprop($Q)))\n | `(iprop(|={ $E1 }β–·=> $P)) => ``(iprop(|={$E1}[$E1]β–·=> iprop($P)))\n | `(iprop($P ={ $E1 }β–·=βˆ— $Q)) => ``(iprop(iprop($P) ={$E1}[$E1]β–·=βˆ— iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 }[ $E2 ]β–·^$n=> $P)) => ``(iprop(|={$E1, $E2}=> β–·^[$n] (|={ $E2, $E1 }=> iprop($P))))\n | `(iprop($P ={ $E1 }[ $E2 ]β–·^$n=βˆ— $Q)) => ``(iprop(iprop($P) -βˆ— |={$E1}[$E2]β–·^$n=> iprop($Q)))\n | `(iprop(|={ $E1 }β–·^$n=> $P)) => ``(iprop(|={$E1}[$E1]β–·^$n=> iprop($P)))\n | `(iprop($P ={ $E1 }β–·^$n=βˆ— $Q)) => ``(iprop(iprop($P) ={$E1}[$E1]β–·^$n=βˆ— iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–  $P)) => ``(Plainly.plainly iprop($P))\n\ndelab_rule Plainly.plainly\n | `($_ $P) => do ``(iprop(β–  $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β– ? $p $P)) => ``(Plainly.plainlyIf $p iprop($P))\n\ndelab_rule Plainly.plainlyIf\n | `($_ $p $P) => do ``(iprop(β– ? $p $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "unpackIprop", "content": "partial def unpackIprop [Monad m] [MonadRef m] [MonadQuotation m] : Term β†’ m Term\n | `(iprop($P)) => do `($P)\n | `($P:ident) => do `($P)\n | `(?$P:ident) => do `(?$P)\n | `(($P)) => do `(($(← unpackIprop P)))\n | `($P $[ $Q]*) => do ``($P $[ $Q]*)\n | `(if $c then $t else $e) => do\n let t ← unpackIprop t\n let e ← unpackIprop e\n `(if $c then $t else $e)\n | `(($P : $t)) => do ``(($(← unpackIprop P) : $t))\n | `($t) => `($t:term)" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "", "content": "instance : Plainly (UPred M) := ⟨UPred.plainly⟩" }, { "name": "plainly", "content": "protected def plainly (P : UPred M) : UPred M where\n holds n _ := P n UCMRA.unit\n mono H _ Hn := P.mono H (CMRA.incN_refl UCMRA.unit) Hn" }, { "name": "BIUpdate", "content": "class BIUpdate (PROP : Type _) [BI PROP] extends BUpd PROP where\n [bupd_ne : OFE.NonExpansive (BUpd.bupd (PROP := PROP))]\n intro {P : PROP} : iprop(P ⊒ |==> P)\n mono {P Q : PROP} : iprop(P ⊒ Q) β†’ iprop(|==> P ⊒ |==> Q)\n trans {P : PROP} : iprop(|==> |==> P ⊒ |==> P)\n frame_r {P R : PROP} : iprop((|==> P) βˆ— R ⊒ |==> (P βˆ— R))" }, { "name": "UPred", "content": "@[ext]\nstructure UPred (M : Type _) [UCMRA M] where\n holds : Nat β†’ M β†’ Prop\n mono {n1 n2 x1 x2} : holds n1 x1 β†’ x1 β‰Ό{n2} x2 β†’ n2 ≀ n1 β†’ holds n2 x2" }, { "name": "IsModal", "content": "class IsModal [BI PROP1] [BI PROP2] (M : PROP1 β†’ PROP2)\n (iaction saction : ModalityAction PROP1 PROP2) where\n spec_intuitionistic : iaction.intuitionistic_action_spec M\n spec_spatial : saction.spatial_action_spec M\n emp : iprop(emp) ⊒ M iprop(emp)\n mono : βˆ€ {P Q}, (P ⊒ Q) β†’ M P ⊒ M Q\n sep : βˆ€ {P Q}, iprop(M P βˆ— M Q) ⊒ M iprop(P βˆ— Q)" }, { "name": "UCMRA", "content": "class UCMRA (Ξ± : Type _) extends CMRA Ξ± where\n unit : Ξ±\n unit_valid : βœ“ unit\n unit_left_id : unit β€’ x ≑ x\n pcore_unit : pcore unit ≑ some unit" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "", "content": "instance : BIPlainly (UPred M) where\n mono H _ _ _ := H _ _ CMRA.unit_validN\n elim_persistently {P} n x Hx := by admit /- proof elided -/" }, { "name": "persistently", "content": "protected def persistently (P : UPred M) : UPred M where\n holds n x := P n (CMRA.core x)\n mono H Hx Hn := P.mono H (CMRA.core_incN_core Hx) Hn" }, { "name": "core", "content": "def core (x : Ξ±) := (pcore x).getD x" }, { "name": "BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "Idempotent", "content": "class Idempotent (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n idem {x : Ξ±} : R (f x x) x" }, { "name": "", "content": "instance : BIPlainlyExists (UPred M) where\n plainly_sExists_1 _ _ _ := fun ⟨_, hp⟩ => ⟨_, ⟨_, rfl⟩, hp⟩" }, { "name": "BIPlainlyExists", "content": "class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where\n plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "imp_intro'", "content": "theorem imp_intro' [BI PROP] {P Q R : PROP} (h : Q ∧ P ⊒ R) : P ⊒ Q β†’ R" }, { "name": "and_comm", "content": "theorem and_comm [BI PROP] {P Q : PROP} : P ∧ Q ⊣⊒ Q ∧ P" }, { "name": "and_symm", "content": "theorem and_symm [BI PROP] {P Q : PROP} : P ∧ Q ⊒ Q ∧ P" }, { "name": "imp_elim'", "content": "theorem imp_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P β†’ R) : P ∧ Q ⊒ R" }, { "name": "pure_elim", "content": "theorem pure_elim [BI PROP] (Ο† : Prop) {Q R : PROP} (h1 : Q ⊒ βŒœΟ†βŒ) (h2 : Ο† β†’ Q ⊒ R) : Q ⊒ R" }, { "name": "and_self", "content": "theorem and_self [BI PROP] {P : PROP} : P ∧ P ⊣⊒ P" }, { "name": "forall_intro", "content": "theorem forall_intro [BI PROP] {P : PROP} {Ξ¨ : Ξ± β†’ PROP} (h : βˆ€ a, P ⊒ Ξ¨ a) : P ⊒ βˆ€ a, Ξ¨ a" }, { "name": "forall_elim", "content": "theorem forall_elim [BI PROP] {Ξ¨ : Ξ± β†’ PROP} (a : Ξ±) : (βˆ€ a, Ξ¨ a) ⊒ Ξ¨ a" }, { "name": "Included.trans", "content": "theorem Included.trans : (x : Ξ±) β‰Ό y β†’ y β‰Ό z β†’ x β‰Ό z" }, { "name": "inc_trans", "content": "theorem inc_trans {x y z : Ξ±} : x β‰Ό y β†’ y β‰Ό z β†’ x β‰Ό z" }, { "name": "op_left_eqv", "content": "theorem op_left_eqv {x y : Ξ±} (z : Ξ±) (e : x ≑ y) : x β€’ z ≑ y β€’ z" }, { "name": "_root_.Iris.OFE.Dist.op_r", "content": "theorem _root_.Iris.OFE.Dist.op_r {x y z : Ξ±} : y ≑{n}≑ z β†’ x β€’ y ≑{n}≑ x β€’ z" }, { "name": "op_right_dist", "content": "theorem op_right_dist (x : Ξ±) {y z : Ξ±} (e : y ≑{n}≑ z) : x β€’ y ≑{n}≑ x β€’ z" }, { "name": "_root_.Iris.OFE.Equiv.op_r", "content": "theorem _root_.Iris.OFE.Equiv.op_r {x y z : Ξ±} : y ≑ z β†’ x β€’ y ≑ x β€’ z" }, { "name": "op_right_eqv", "content": "theorem op_right_eqv (x : Ξ±) {y z : Ξ±} (e : y ≑ z) : x β€’ y ≑ x β€’ z" }, { "name": "IncludedN.trans", "content": "theorem IncludedN.trans : (x : Ξ±) β‰Ό{n} y β†’ y β‰Ό{n} z β†’ x β‰Ό{n} z" }, { "name": "incN_trans", "content": "theorem incN_trans {x y z : Ξ±} : x β‰Ό{n} y β†’ y β‰Ό{n} z β†’ x β‰Ό{n} z" }, { "name": "op_left_dist", "content": "theorem op_left_dist {x y : Ξ±} (z : Ξ±) (e : x ≑{n}≑ y) : x β€’ z ≑{n}≑ y β€’ z" }, { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "persistently_and_emp_elim", "content": "theorem persistently_and_emp_elim {P : PROP} [BI PROP] : emp ∧ <pers> P ⊒ P" }, { "name": "sep_emp", "content": "theorem sep_emp [BI PROP] {P : PROP} : P βˆ— emp ⊣⊒ P" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "and_forall_bool", "content": "theorem and_forall_bool [BI PROP] {P Q : PROP} :\n P ∧ Q ⊣⊒ Β«forallΒ» (fun b : Bool => if b then P else Q)" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" }, { "name": "true_and", "content": "theorem true_and [BI PROP] {P : PROP} : True ∧ P ⊣⊒ P" }, { "name": "forall_mono", "content": "@[rw_mono_rule]\ntheorem forall_mono [BI PROP] {Ξ¦ Ξ¨ : Ξ± β†’ PROP} (h : βˆ€ a, Ξ¦ a ⊒ Ξ¨ a) : (βˆ€ a, Ξ¦ a) ⊒ βˆ€ a, Ξ¨ a" }, { "name": "and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" } ]
[ { "name": "Iris.Plainly", "content": "class Plainly (PROP : Type _) where\n plainly : PROP β†’ PROP" }, { "name": "Iris.Plainly.plainlyIf", "content": "def Plainly.plainlyIf [Iris.BI.BIBase PROP] [Plainly PROP] (p : Bool) (P : PROP) : PROP :=\n iprop(if p then β–  P else P)" }, { "name": "Iris.BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "Iris.BIPlainlyExists", "content": "class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where\n plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p" } ]
[ { "name": "Iris.BI.plainly_forall_2", "content": "theorem plainly_forall_2 {Ξ¨ : Ξ± β†’ PROP} : (βˆ€ a, β–  (Ξ¨ a)) ⊒ β–  (βˆ€ a, Ξ¨ a)" } ]
import Iris.BI.Classes import Iris.BI.BI import Iris.BI.DerivedLaws import Iris.Algebra namespace Iris open BI class Plainly (PROP : Type _) where plainly : PROP β†’ PROP def Plainly.plainlyIf [Iris.BI.BIBase PROP] [Plainly PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–  P else P) class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))] mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q elim_persistently {P : PROP} : β–  P ⊒ <pers> P idem {P : PROP} : β–  P ⊒ β–  β–  P plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦ plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q) emp_intro {P : PROP} : P ⊒ β–  emp plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p namespace BI open Iris.Std section PlainlyLaws open BIPlainly variable [BI PROP] [BIPlainly PROP] variable {P Q R : PROP}
theorem plainly_persistently_elim : β–  <pers> P ⊣⊒ β–  P :=
:= by constructor Β· refine (true_and.2.trans <| and_mono emp_intro .rfl).trans ?_ refine .trans ?_ (mono <| and_forall_bool.2.trans persistently_and_emp_elim) refine and_forall_bool.1.trans ?_ refine .trans ?_ plainly_forall_2 refine forall_mono ?_ exact (Β·.casesOn .rfl .rfl) Β· exact idem.trans <| mono elim_persistently
6
75
false
Framework
231
Iris.fixpoint_unique
theorem fixpoint_unique [COFE Ξ±] [Inhabited Ξ±] {f : Ξ± -c> Ξ±} {x : Ξ±} (H : x ≑ f x) : x ≑ fixpoint f
iris-lean
src/Iris/Algebra/OFE.lean
[ "import src/Iris/Algebra/Excl.lean", "import src/Iris/Instances/UPred/Instance.lean", "import src/Iris/Algebra/UPred.lean", "import src/Iris/Algebra/CMRA.lean", "import src/Iris/Algebra/Agree_task.lean", "import src/Iris/Algebra/COFESolver.lean", "import src/Iris/Algebra/Heap.lean" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Dist", "module": "Mathlib.Topology.MetricSpace.Pseudo.Defs" }, { "name": "Equiv", "module": "Mathlib.Logic.Equiv.Defs" }, { "name": "Nat.succ", "module": "Init.Prelude" }, { "name": "k", "module": "QqTest.matching" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "", "content": "instance : OFE.Discrete (DFrac F) := ⟨congrArg id⟩" }, { "name": "Agree.dist", "content": "def Agree.dist (n : Nat) (x y : Agree Ξ±) : Prop :=\n (βˆ€ a ∈ x.car, βˆƒ b ∈ y.car, a ≑{n}≑ b) ∧\n (βˆ€ b ∈ y.car, βˆƒ a ∈ x.car, a ≑{n}≑ b)" }, { "name": "", "content": "instance : OFE (Tower F) where\n Equiv f g := βˆ€ k, f k ≑ g k\n Dist n f g := βˆ€ k, f k ≑{n}≑ g k\n dist_eqv := {\n refl _ _ := dist_eqv.refl _\n symm h _ := dist_eqv.symm (h _)\n trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _)\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "", "content": "instance : OFE.NonExpansive (BUpd.bupd (PROP := UPred M)) := bupd_ne" }, { "name": "bupd_ne", "content": "instance bupd_ne : OFE.NonExpansive (bupd : UPred M β†’ UPred M) where\n ne n x1 x2 Hx m y Hm Hv := by admit /- proof elided -/" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "later_contractive", "content": "instance later_contractive : OFE.Contractive UPred.later (Ξ± := UPred M) where\n distLater_dist {n x y} Hl :=\n match n with\n | 0 => by admit /- proof elided -/\n | n + 1 => fun\n | 0 => by admit /- proof elided -/\n | n' + 1 => fun x' Hn' Hx' => Hl _ Hn' _ _ (Nat.le_refl _) (CMRA.validN_succ Hx')" }, { "name": "later", "content": "protected def later (P : UPred M) : UPred M where\n holds n x := match n with | 0 => True | Nat.succ n' => P n' x\n mono {n₁ nβ‚‚} := by admit /- proof elided -/" }, { "name": "BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "BIUpdate", "content": "class BIUpdate (PROP : Type _) [BI PROP] extends BUpd PROP where\n [bupd_ne : OFE.NonExpansive (BUpd.bupd (PROP := PROP))]\n intro {P : PROP} : iprop(P ⊒ |==> P)\n mono {P Q : PROP} : iprop(P ⊒ Q) β†’ iprop(|==> P ⊒ |==> Q)\n trans {P : PROP} : iprop(|==> |==> P ⊒ |==> P)\n frame_r {P R : PROP} : iprop((|==> P) βˆ— R ⊒ |==> (P βˆ— R))" }, { "name": "UPred", "content": "@[ext]\nstructure UPred (M : Type _) [UCMRA M] where\n holds : Nat β†’ M β†’ Prop\n mono {n1 n2 x1 x2} : holds n1 x1 β†’ x1 β‰Ό{n2} x2 β†’ n2 ≀ n1 β†’ holds n2 x2" }, { "name": "IsModal", "content": "class IsModal [BI PROP1] [BI PROP2] (M : PROP1 β†’ PROP2)\n (iaction saction : ModalityAction PROP1 PROP2) where\n spec_intuitionistic : iaction.intuitionistic_action_spec M\n spec_spatial : saction.spatial_action_spec M\n emp : iprop(emp) ⊒ M iprop(emp)\n mono : βˆ€ {P Q}, (P ⊒ Q) β†’ M P ⊒ M Q\n sep : βˆ€ {P Q}, iprop(M P βˆ— M Q) ⊒ M iprop(P βˆ— Q)" }, { "name": "UCMRA", "content": "class UCMRA (Ξ± : Type _) extends CMRA Ξ± where\n unit : Ξ±\n unit_valid : βœ“ unit\n unit_left_id : unit β€’ x ≑ x\n pcore_unit : pcore unit ≑ some unit" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "instOFE", "content": "instance instOFE [Store T K V] [OFE V] : OFE T where\n Equiv s0 s1 := get s0 ≑ get s1\n Dist n s0 s1 := get s0 ≑{n}≑ get s1\n dist_eqv := ⟨fun _ => .of_eq rfl, (Β·.symm), (Β·.trans Β·)⟩\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Store.Equiv", "content": "@[simp] def Store.Equiv [Store T K V] (t1 t2 : T) : Prop := get t1 = get t2" }, { "name": "Store.Equiv_trans", "content": "instance Store.Equiv_trans [Store T K V] : Trans Equiv (Equiv (T := T)) Equiv := ⟨by admit /- proof elided -/\n⟩" }, { "name": "[CMRA", "content": "instance [CMRA Ξ²] : OFE (Ξ± -C> Ξ²) where\n Equiv f g := f.toHom ≑ g.toHom\n Dist n f g := f.toHom ≑{n}≑ g.toHom\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "[OFE", "content": "instance [OFE Ξ±] [IsCOFE Ξ±] : IsCOFE (Excl Ξ±) where\n compl c := (c 0).map fun x => IsCOFE.compl (exclChain c x)\n conv_compl {n} c := by admit /- proof elided -/" }, { "name": "(k", "content": "instance (k : Nat) : NonExpansive (fun X : Tower F => X.val k) := ⟨fun _ _ _ => (Β· _)⟩" }, { "name": "[OFE", "content": "instance [OFE Ξ±] : NonExpansive excl (Ξ± := Ξ±) where\n ne _ _ _ a := a" }, { "name": "get_ne", "content": "instance get_ne [Store T K V] [OFE V] (k : K) : NonExpansive (get Β· k : T β†’ V) where\n ne {_ _ _} Ht := Ht k" }, { "name": "[Store", "content": "instance [Store T1 K V1] [Store T2 K V2] [OFE V1] [OFE V2] (f : K β†’ V1 β†’ V2)\n [βˆ€ k, NonExpansive (f k)] [HasStoreMap T1 T2 K V1 V2] : NonExpansive (dmap f : T1 β†’ T2) where\n ne _ {_ _} H k := by admit /- proof elided -/" }, { "name": "HasStoreMap", "content": "class HasStoreMap (T1 T2 : Type _) (K V1 V2 : outParam (Type _)) [Store T1 K V1] [Store T2 K V2] where\n \n dmap (f : K β†’ V1 β†’ V2) : T1 β†’ T2\n get_dmap : get (dmap f t) k = f k (get t k)" }, { "name": "", "content": "instance : NonExpansive (pcore (Ξ± := Ξ±)) where\n ne n x {y} e := by admit /- proof elided -/" }, { "name": "[Heap", "content": "instance [Heap T K V] [OFE V] (op : V β†’ V β†’ V) [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (merge (T := T) op) where\n ne _ {_ _} Ht {_ _} Hs k := by admit /- proof elided -/" }, { "name": "Heap.instCOFE", "content": "instance Heap.instCOFE [Heap T K V] [COFE V] : COFE T where\n compl c := hmap (fun _ => COFE.compl <| c.map ⟨_, Store.get_ne ·⟩) (c 0)\n conv_compl {_ c} k := by admit /- proof elided -/" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -C> \" => Hom" } ]
[ { "name": "Nat.lt_of_le_of_ne", "module": "Init.Prelude" }, { "name": "Nat.le_of_lt_succ", "module": "Init.Prelude" }, { "name": "Nat.lt_succ_self", "module": "Init.Prelude" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Iris.OFE", "content": "class OFE (Ξ± : Type _) where\n Equiv : Ξ± β†’ Ξ± β†’ Prop\n Dist : Nat β†’ Ξ± β†’ Ξ± β†’ Prop\n dist_eqv : Equivalence (Dist n)\n equiv_dist : Equiv x y ↔ βˆ€ n, Dist n x y\n dist_lt : Dist n x y β†’ m < n β†’ Dist m x y" }, { "name": "Iris.OFE.NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "Iris.OFE.id_ne", "content": "instance id_ne [OFE Ξ±] : NonExpansive (@id Ξ±) := ⟨fun _ _ _ h => h⟩" }, { "name": "Iris.OFE.NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "Iris.OFE.DistLater", "content": "def DistLater [OFE Ξ±] (n : Nat) (x y : Ξ±) : Prop := βˆ€ m, m < n β†’ x ≑{m}≑ y" }, { "name": "Iris.OFE.Contractive", "content": "class Contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n distLater_dist : DistLater n x y β†’ f x ≑{n}≑ f y" }, { "name": "Iris.OFE.ne_of_contractive", "content": "instance ne_of_contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] : NonExpansive f where\n ne := fun _ _ _ h => Contractive.distLater_dist (Dist.distLater h)" }, { "name": "Iris.OFE._inst_Ξ²", "content": "instance [OFE Ξ±] [OFE Ξ²] {x : Ξ²} : Contractive (fun _ : Ξ± => x) where\n distLater_dist := fun _ => Dist.rfl" }, { "name": "Iris.OFE.Hom", "content": "@[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n f : Ξ± β†’ Ξ²\n ne : NonExpansive f" }, { "name": "Iris.OFE._inst_Ξ±", "content": "instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -n> Ξ²) : NonExpansive f := f.ne" }, { "name": "Iris.OFE.ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "Iris.OFE._inst_Ξ±", "content": "instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -c> Ξ²) : Contractive f := f.contractive" }, { "name": "Iris.OFE._inst_OFE", "content": "instance : OFE Unit where\n Equiv _ _ := True\n Dist _ _ _ := True\n dist_eqv := ⟨fun _ => ⟨⟩, id, fun _ => id⟩\n equiv_dist := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] : OFE (ULift Ξ±) where\n Equiv x y := x.down ≑ y.down\n Dist n x y := x.down ≑{n}≑ y.down\n dist_eqv := InvImage.equivalence dist_eqv\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] : OFE (Option Ξ±) where\n Equiv := Option.Forallβ‚‚ Equiv\n Dist n := Option.Forallβ‚‚ (Dist n)\n dist_eqv := Option.Forallβ‚‚.equivalence dist_eqv\n equiv_dist {x y} := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE.Discrete Ξ±] : OFE.Discrete (Option Ξ±) where\n discrete_0 {mx my} e :=\n match mx, my with\n | none, none => e\n | none, some _ => e\n | some _, none => e\n | some x, some y => show x ≑ y from discrete_0 e" }, { "name": "Iris.OFE.OFE", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Iris.OFE.Option", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_Ξ±", "content": "instance [OFEFun (Ξ² : Ξ± β†’ _)] : OFE ((x : Ξ±) β†’ Ξ² x) where\n Equiv f g := βˆ€ x, f x ≑ g x\n Dist n f g := βˆ€ x, f x ≑{n}≑ g x\n dist_eqv := {\n refl _ _ := dist_eqv.refl _\n symm h _ := dist_eqv.symm (h _)\n trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _)\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -n> Ξ²) where\n Equiv f g := f.f ≑ g.f\n Dist n f g := f.f ≑{n}≑ g.f\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -c> Ξ²) where\n Equiv f g := Equiv f.toHom g.toHom\n Dist n f g := Dist n f.toHom g.toHom\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± Γ— Ξ²) where\n Equiv a b := a.1 ≑ b.1 ∧ a.2 ≑ b.2\n Dist n a b := a.1 ≑{n}≑ b.1 ∧ a.2 ≑{n}≑ b.2\n dist_eqv := {\n refl _ := ⟨dist_eqv.refl _, dist_eqv.refl _⟩\n symm h := ⟨dist_eqv.symm h.1, dist_eqv.symm h.2⟩\n trans h1 h2 := ⟨dist_eqv.trans h1.1 h2.1, dist_eqv.trans h1.2 h2.2⟩\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "Iris.OFE.Iso", "content": "@[ext] structure Iso (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n hom : Ξ± -n> Ξ²\n inv : Ξ² -n> Ξ±\n hom_inv : hom (inv x) ≑ x\n inv_hom : inv (hom x) ≑ x" }, { "name": "Iris.OFE._inst_Iso", "content": "instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.hom := iso.hom.ne" }, { "name": "Iris.OFE._inst_Iso", "content": "instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.inv := iso.inv.ne" }, { "name": "Iris.OFE.Iso.symm", "content": "def Iso.symm [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : Iso Ξ² Ξ± where\n hom := iso.inv\n inv := iso.hom\n hom_inv := by admit /- proof elided -/" }, { "name": "Iris.Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "Iris.IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Iris.LeibnizO", "content": "@[ext] structure LeibnizO (Ξ± : Type _) where\n car : Ξ±" }, { "name": "Iris.optionChain", "content": "def optionChain (c : Chain (Option Ξ±)) (x : Ξ±) : Chain Ξ± :=" }, { "name": "Iris.isCOFE_option", "content": "instance isCOFE_option [IsCOFE Ξ±] : IsCOFE (Option Ξ±) where\n compl c := (c 0).map fun x => IsCOFE.compl (optionChain c x)\n conv_compl {n} c := by admit /- proof elided -/" }, { "name": "Iris.Fixpoint.chain", "content": "def Fixpoint.chain [OFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Chain Ξ± where\n chain n := Nat.repeat f (n + 1) default\n cauchy {n} := by admit /- proof elided -/" }, { "name": "Iris.fixpoint", "content": "def fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Ξ± :=\n COFE.compl <| Fixpoint.chain f\n\nnonrec abbrev OFE.ContractiveHom.fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) : Ξ± := fixpoint f.f" } ]
[ { "name": "Iris.OFE.Dist.lt", "content": "theorem Dist.lt [OFE Ξ±] {m n} {x y : Ξ±} : x ≑{n}≑ y β†’ m < n β†’ x ≑{m}≑ y" }, { "name": "Iris.OFE.Dist.le", "content": "theorem Dist.le [OFE Ξ±] {m n} {x y : Ξ±} (h : x ≑{n}≑ y) (h' : m ≀ n) : x ≑{m}≑ y" }, { "name": "Iris.OFE.Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "Iris.OFE.Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Iris.OFE.Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "Iris.OFE.equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Iris.OFE.Equiv.symm", "content": "@[symm] theorem Equiv.symm [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ x" }, { "name": "Iris.OFE.Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "Iris.OFE.Equiv.dist", "content": "theorem Equiv.dist [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ x ≑{n}≑ y" }, { "name": "Iris.OFE.DistLater.symm", "content": "@[symm] theorem DistLater.symm [OFE Ξ±] {n} {x : Ξ±} (h : DistLater n x y) : DistLater n y x" }, { "name": "Iris.OFE.DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" }, { "name": "Iris.OFE.distLater_zero", "content": "@[simp] theorem distLater_zero [OFE Ξ±] {x y : Ξ±} : DistLater 0 x y" }, { "name": "Iris.OFE.distLater_succ", "content": "theorem distLater_succ [OFE Ξ±] {n} {x y : Ξ±} : DistLater n.succ x y ↔ x ≑{n}≑ y" }, { "name": "Iris.OFE.Contractive.zero", "content": "@[simp] theorem Contractive.zero [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] {x y} :\n f x ≑{0}≑ f y" }, { "name": "Iris.OFE.Contractive.succ", "content": "theorem Contractive.succ [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] {n x y}\n (h : x ≑{n}≑ y) : f x ≑{n.succ}≑ f y" }, { "name": "Iris.fixpoint_unfold", "content": "theorem fixpoint_unfold [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) :\n fixpoint f ≑ f (fixpoint f)" } ]
namespace Iris class OFE (Ξ± : Type _) where Equiv : Ξ± β†’ Ξ± β†’ Prop Dist : Nat β†’ Ξ± β†’ Ξ± β†’ Prop dist_eqv : Equivalence (Dist n) equiv_dist : Equiv x y ↔ βˆ€ n, Dist n x y dist_lt : Dist n x y β†’ m < n β†’ Dist m x y open OFE scoped infix:40 " ≑ " => OFE.Equiv scoped notation:40 x " ≑{" n "}≑ " y:41 => OFE.Dist n x y namespace OFE class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚ instance id_ne [OFE Ξ±] : NonExpansive (@id Ξ±) := ⟨fun _ _ _ h => h⟩ class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚ def DistLater [OFE Ξ±] (n : Nat) (x y : Ξ±) : Prop := βˆ€ m, m < n β†’ x ≑{m}≑ y class Contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where distLater_dist : DistLater n x y β†’ f x ≑{n}≑ f y instance ne_of_contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] : NonExpansive f where ne := fun _ _ _ h => Contractive.distLater_dist (Dist.distLater h) instance [OFE Ξ±] [OFE Ξ²] {x : Ξ²} : Contractive (fun _ : Ξ± => x) where distLater_dist := fun _ => Dist.rfl @[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where f : Ξ± β†’ Ξ² ne : NonExpansive f @[inherit_doc] infixr:25 " -n> " => Hom instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -n> Ξ²) : NonExpansive f := f.ne @[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where [contractive : Contractive f] ne := ne_of_contractive f infixr:25 " -c> " => ContractiveHom instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -c> Ξ²) : Contractive f := f.contractive instance : OFE Unit where Equiv _ _ := True Dist _ _ _ := True dist_eqv := ⟨fun _ => ⟨⟩, id, fun _ => id⟩ equiv_dist := by admit /- proof elided -/ instance [OFE Ξ±] : OFE (ULift Ξ±) where Equiv x y := x.down ≑ y.down Dist n x y := x.down ≑{n}≑ y.down dist_eqv := InvImage.equivalence dist_eqv equiv_dist := equiv_dist dist_lt := dist_lt instance [OFE Ξ±] : OFE (Option Ξ±) where Equiv := Option.Forallβ‚‚ Equiv Dist n := Option.Forallβ‚‚ (Dist n) dist_eqv := Option.Forallβ‚‚.equivalence dist_eqv equiv_dist {x y} := by admit /- proof elided -/ instance [OFE Ξ±] [OFE.Discrete Ξ±] : OFE.Discrete (Option Ξ±) where discrete_0 {mx my} e := match mx, my with | none, none => e | none, some _ => e | some _, none => e | some x, some y => show x ≑ y from discrete_0 e instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩ instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] : NonExpansiveβ‚‚ (Option.merge op) where ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/ instance [OFEFun (Ξ² : Ξ± β†’ _)] : OFE ((x : Ξ±) β†’ Ξ² x) where Equiv f g := βˆ€ x, f x ≑ g x Dist n f g := βˆ€ x, f x ≑{n}≑ g x dist_eqv := { refl _ _ := dist_eqv.refl _ symm h _ := dist_eqv.symm (h _) trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _) } equiv_dist {_ _} := by admit /- proof elided -/ instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -n> Ξ²) where Equiv f g := f.f ≑ g.f Dist n f g := f.f ≑{n}≑ g.f dist_eqv := { refl _ := dist_eqv.refl _ symm h := dist_eqv.symm h trans h1 h2 := dist_eqv.trans h1 h2 } equiv_dist := equiv_dist dist_lt := dist_lt instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -c> Ξ²) where Equiv f g := Equiv f.toHom g.toHom Dist n f g := Dist n f.toHom g.toHom dist_eqv := { refl _ := dist_eqv.refl _ symm h := dist_eqv.symm h trans h1 h2 := dist_eqv.trans h1 h2 } equiv_dist := equiv_dist dist_lt := dist_lt instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± Γ— Ξ²) where Equiv a b := a.1 ≑ b.1 ∧ a.2 ≑ b.2 Dist n a b := a.1 ≑{n}≑ b.1 ∧ a.2 ≑{n}≑ b.2 dist_eqv := { refl _ := ⟨dist_eqv.refl _, dist_eqv.refl _⟩ symm h := ⟨dist_eqv.symm h.1, dist_eqv.symm h.2⟩ trans h1 h2 := ⟨dist_eqv.trans h1.1 h2.1, dist_eqv.trans h1.2 h2.2⟩ } equiv_dist {_ _} := by admit /- proof elided -/ @[ext] structure Iso (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where hom : Ξ± -n> Ξ² inv : Ξ² -n> Ξ± hom_inv : hom (inv x) ≑ x inv_hom : inv (hom x) ≑ x instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.hom := iso.hom.ne instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.inv := iso.inv.ne def Iso.symm [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : Iso Ξ² Ξ± where hom := iso.inv inv := iso.hom hom_inv := by admit /- proof elided -/ end OFE structure Chain (Ξ± : Type _) [OFE Ξ±] where chain : Nat β†’ Ξ± cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n namespace Chain end Chain class IsCOFE (Ξ± : Type _) [OFE Ξ±] where compl : Chain Ξ± β†’ Ξ± conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n namespace COFE end COFE @[ext] structure LeibnizO (Ξ± : Type _) where car : Ξ± section DiscreteFunOF open COFE end DiscreteFunOF section Option variable [OFE Ξ±] def optionChain (c : Chain (Option Ξ±)) (x : Ξ±) : Chain Ξ± := instance isCOFE_option [IsCOFE Ξ±] : IsCOFE (Option Ξ±) where compl c := (c 0).map fun x => IsCOFE.compl (optionChain c x) conv_compl {n} c := by admit /- proof elided -/ end Option section OptionOF open COFE variable (F : OFunctorPre) end OptionOF section Fixpoint def Fixpoint.chain [OFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Chain Ξ± where chain n := Nat.repeat f (n + 1) default cauchy {n} := by admit /- proof elided -/ def fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Ξ± := COFE.compl <| Fixpoint.chain f nonrec abbrev OFE.ContractiveHom.fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) : Ξ± := fixpoint f.f
theorem fixpoint_unique [COFE Ξ±] [Inhabited Ξ±] {f : Ξ± -c> Ξ±} {x : Ξ±} (H : x ≑ f x) : x ≑ fixpoint f :=
:= by refine equiv_dist.mpr fun n => ?_ induction n with refine H.dist.trans <| .trans ?_ (fixpoint_unfold f).dist.symm | zero => exact Contractive.zero f.f | succ _ IH => exact Contractive.succ f.f IH
6
45
false
Framework
232
Iris.fixpoint_unfold
theorem fixpoint_unfold [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) : fixpoint f ≑ f (fixpoint f)
iris-lean
src/Iris/Algebra/OFE.lean
[ "import src/Iris/Algebra/Excl.lean", "import src/Iris/Instances/UPred/Instance.lean", "import src/Iris/Algebra/UPred.lean", "import src/Iris/Algebra/CMRA.lean", "import src/Iris/Algebra/Agree_task.lean", "import src/Iris/Algebra/COFESolver.lean", "import src/Iris/Algebra/Heap.lean" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Dist", "module": "Mathlib.Topology.MetricSpace.Pseudo.Defs" }, { "name": "Equiv", "module": "Mathlib.Logic.Equiv.Defs" }, { "name": "Nat.succ", "module": "Init.Prelude" }, { "name": "k", "module": "QqTest.matching" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "", "content": "instance : OFE.Discrete (DFrac F) := ⟨congrArg id⟩" }, { "name": "Agree.dist", "content": "def Agree.dist (n : Nat) (x y : Agree Ξ±) : Prop :=\n (βˆ€ a ∈ x.car, βˆƒ b ∈ y.car, a ≑{n}≑ b) ∧\n (βˆ€ b ∈ y.car, βˆƒ a ∈ x.car, a ≑{n}≑ b)" }, { "name": "", "content": "instance : OFE (Tower F) where\n Equiv f g := βˆ€ k, f k ≑ g k\n Dist n f g := βˆ€ k, f k ≑{n}≑ g k\n dist_eqv := {\n refl _ _ := dist_eqv.refl _\n symm h _ := dist_eqv.symm (h _)\n trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _)\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "", "content": "instance : OFE.NonExpansive (BUpd.bupd (PROP := UPred M)) := bupd_ne" }, { "name": "bupd_ne", "content": "instance bupd_ne : OFE.NonExpansive (bupd : UPred M β†’ UPred M) where\n ne n x1 x2 Hx m y Hm Hv := by admit /- proof elided -/" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "later_contractive", "content": "instance later_contractive : OFE.Contractive UPred.later (Ξ± := UPred M) where\n distLater_dist {n x y} Hl :=\n match n with\n | 0 => by admit /- proof elided -/\n | n + 1 => fun\n | 0 => by admit /- proof elided -/\n | n' + 1 => fun x' Hn' Hx' => Hl _ Hn' _ _ (Nat.le_refl _) (CMRA.validN_succ Hx')" }, { "name": "later", "content": "protected def later (P : UPred M) : UPred M where\n holds n x := match n with | 0 => True | Nat.succ n' => P n' x\n mono {n₁ nβ‚‚} := by admit /- proof elided -/" }, { "name": "BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "BIUpdate", "content": "class BIUpdate (PROP : Type _) [BI PROP] extends BUpd PROP where\n [bupd_ne : OFE.NonExpansive (BUpd.bupd (PROP := PROP))]\n intro {P : PROP} : iprop(P ⊒ |==> P)\n mono {P Q : PROP} : iprop(P ⊒ Q) β†’ iprop(|==> P ⊒ |==> Q)\n trans {P : PROP} : iprop(|==> |==> P ⊒ |==> P)\n frame_r {P R : PROP} : iprop((|==> P) βˆ— R ⊒ |==> (P βˆ— R))" }, { "name": "UPred", "content": "@[ext]\nstructure UPred (M : Type _) [UCMRA M] where\n holds : Nat β†’ M β†’ Prop\n mono {n1 n2 x1 x2} : holds n1 x1 β†’ x1 β‰Ό{n2} x2 β†’ n2 ≀ n1 β†’ holds n2 x2" }, { "name": "IsModal", "content": "class IsModal [BI PROP1] [BI PROP2] (M : PROP1 β†’ PROP2)\n (iaction saction : ModalityAction PROP1 PROP2) where\n spec_intuitionistic : iaction.intuitionistic_action_spec M\n spec_spatial : saction.spatial_action_spec M\n emp : iprop(emp) ⊒ M iprop(emp)\n mono : βˆ€ {P Q}, (P ⊒ Q) β†’ M P ⊒ M Q\n sep : βˆ€ {P Q}, iprop(M P βˆ— M Q) ⊒ M iprop(P βˆ— Q)" }, { "name": "UCMRA", "content": "class UCMRA (Ξ± : Type _) extends CMRA Ξ± where\n unit : Ξ±\n unit_valid : βœ“ unit\n unit_left_id : unit β€’ x ≑ x\n pcore_unit : pcore unit ≑ some unit" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "instOFE", "content": "instance instOFE [Store T K V] [OFE V] : OFE T where\n Equiv s0 s1 := get s0 ≑ get s1\n Dist n s0 s1 := get s0 ≑{n}≑ get s1\n dist_eqv := ⟨fun _ => .of_eq rfl, (Β·.symm), (Β·.trans Β·)⟩\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Store.Equiv", "content": "@[simp] def Store.Equiv [Store T K V] (t1 t2 : T) : Prop := get t1 = get t2" }, { "name": "Store.Equiv_trans", "content": "instance Store.Equiv_trans [Store T K V] : Trans Equiv (Equiv (T := T)) Equiv := ⟨by admit /- proof elided -/\n⟩" }, { "name": "[CMRA", "content": "instance [CMRA Ξ²] : OFE (Ξ± -C> Ξ²) where\n Equiv f g := f.toHom ≑ g.toHom\n Dist n f g := f.toHom ≑{n}≑ g.toHom\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "[OFE", "content": "instance [OFE Ξ±] [IsCOFE Ξ±] : IsCOFE (Excl Ξ±) where\n compl c := (c 0).map fun x => IsCOFE.compl (exclChain c x)\n conv_compl {n} c := by admit /- proof elided -/" }, { "name": "(k", "content": "instance (k : Nat) : NonExpansive (fun X : Tower F => X.val k) := ⟨fun _ _ _ => (Β· _)⟩" }, { "name": "[OFE", "content": "instance [OFE Ξ±] : NonExpansive excl (Ξ± := Ξ±) where\n ne _ _ _ a := a" }, { "name": "get_ne", "content": "instance get_ne [Store T K V] [OFE V] (k : K) : NonExpansive (get Β· k : T β†’ V) where\n ne {_ _ _} Ht := Ht k" }, { "name": "[Store", "content": "instance [Store T1 K V1] [Store T2 K V2] [OFE V1] [OFE V2] (f : K β†’ V1 β†’ V2)\n [βˆ€ k, NonExpansive (f k)] [HasStoreMap T1 T2 K V1 V2] : NonExpansive (dmap f : T1 β†’ T2) where\n ne _ {_ _} H k := by admit /- proof elided -/" }, { "name": "HasStoreMap", "content": "class HasStoreMap (T1 T2 : Type _) (K V1 V2 : outParam (Type _)) [Store T1 K V1] [Store T2 K V2] where\n \n dmap (f : K β†’ V1 β†’ V2) : T1 β†’ T2\n get_dmap : get (dmap f t) k = f k (get t k)" }, { "name": "", "content": "instance : NonExpansive (pcore (Ξ± := Ξ±)) where\n ne n x {y} e := by admit /- proof elided -/" }, { "name": "[Heap", "content": "instance [Heap T K V] [OFE V] (op : V β†’ V β†’ V) [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (merge (T := T) op) where\n ne _ {_ _} Ht {_ _} Hs k := by admit /- proof elided -/" }, { "name": "Heap.instCOFE", "content": "instance Heap.instCOFE [Heap T K V] [COFE V] : COFE T where\n compl c := hmap (fun _ => COFE.compl <| c.map ⟨_, Store.get_ne ·⟩) (c 0)\n conv_compl {_ c} k := by admit /- proof elided -/" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -C> \" => Hom" } ]
[ { "name": "Nat.lt_of_le_of_ne", "module": "Init.Prelude" }, { "name": "Nat.le_of_lt_succ", "module": "Init.Prelude" }, { "name": "Nat.lt_succ_self", "module": "Init.Prelude" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Iris.OFE", "content": "class OFE (Ξ± : Type _) where\n Equiv : Ξ± β†’ Ξ± β†’ Prop\n Dist : Nat β†’ Ξ± β†’ Ξ± β†’ Prop\n dist_eqv : Equivalence (Dist n)\n equiv_dist : Equiv x y ↔ βˆ€ n, Dist n x y\n dist_lt : Dist n x y β†’ m < n β†’ Dist m x y" }, { "name": "Iris.OFE.NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "Iris.OFE.id_ne", "content": "instance id_ne [OFE Ξ±] : NonExpansive (@id Ξ±) := ⟨fun _ _ _ h => h⟩" }, { "name": "Iris.OFE.NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "Iris.OFE.DistLater", "content": "def DistLater [OFE Ξ±] (n : Nat) (x y : Ξ±) : Prop := βˆ€ m, m < n β†’ x ≑{m}≑ y" }, { "name": "Iris.OFE.Contractive", "content": "class Contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n distLater_dist : DistLater n x y β†’ f x ≑{n}≑ f y" }, { "name": "Iris.OFE.ne_of_contractive", "content": "instance ne_of_contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] : NonExpansive f where\n ne := fun _ _ _ h => Contractive.distLater_dist (Dist.distLater h)" }, { "name": "Iris.OFE._inst_Ξ²", "content": "instance [OFE Ξ±] [OFE Ξ²] {x : Ξ²} : Contractive (fun _ : Ξ± => x) where\n distLater_dist := fun _ => Dist.rfl" }, { "name": "Iris.OFE.Hom", "content": "@[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n f : Ξ± β†’ Ξ²\n ne : NonExpansive f" }, { "name": "Iris.OFE._inst_Ξ±", "content": "instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -n> Ξ²) : NonExpansive f := f.ne" }, { "name": "Iris.OFE.ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "Iris.OFE._inst_Ξ±", "content": "instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -c> Ξ²) : Contractive f := f.contractive" }, { "name": "Iris.OFE._inst_OFE", "content": "instance : OFE Unit where\n Equiv _ _ := True\n Dist _ _ _ := True\n dist_eqv := ⟨fun _ => ⟨⟩, id, fun _ => id⟩\n equiv_dist := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] : OFE (ULift Ξ±) where\n Equiv x y := x.down ≑ y.down\n Dist n x y := x.down ≑{n}≑ y.down\n dist_eqv := InvImage.equivalence dist_eqv\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] : OFE (Option Ξ±) where\n Equiv := Option.Forallβ‚‚ Equiv\n Dist n := Option.Forallβ‚‚ (Dist n)\n dist_eqv := Option.Forallβ‚‚.equivalence dist_eqv\n equiv_dist {x y} := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE.Discrete Ξ±] : OFE.Discrete (Option Ξ±) where\n discrete_0 {mx my} e :=\n match mx, my with\n | none, none => e\n | none, some _ => e\n | some _, none => e\n | some x, some y => show x ≑ y from discrete_0 e" }, { "name": "Iris.OFE.OFE", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Iris.OFE.Option", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_Ξ±", "content": "instance [OFEFun (Ξ² : Ξ± β†’ _)] : OFE ((x : Ξ±) β†’ Ξ² x) where\n Equiv f g := βˆ€ x, f x ≑ g x\n Dist n f g := βˆ€ x, f x ≑{n}≑ g x\n dist_eqv := {\n refl _ _ := dist_eqv.refl _\n symm h _ := dist_eqv.symm (h _)\n trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _)\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -n> Ξ²) where\n Equiv f g := f.f ≑ g.f\n Dist n f g := f.f ≑{n}≑ g.f\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -c> Ξ²) where\n Equiv f g := Equiv f.toHom g.toHom\n Dist n f g := Dist n f.toHom g.toHom\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Iris.OFE._inst_OFE", "content": "instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± Γ— Ξ²) where\n Equiv a b := a.1 ≑ b.1 ∧ a.2 ≑ b.2\n Dist n a b := a.1 ≑{n}≑ b.1 ∧ a.2 ≑{n}≑ b.2\n dist_eqv := {\n refl _ := ⟨dist_eqv.refl _, dist_eqv.refl _⟩\n symm h := ⟨dist_eqv.symm h.1, dist_eqv.symm h.2⟩\n trans h1 h2 := ⟨dist_eqv.trans h1.1 h2.1, dist_eqv.trans h1.2 h2.2⟩\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "Iris.OFE.Iso", "content": "@[ext] structure Iso (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n hom : Ξ± -n> Ξ²\n inv : Ξ² -n> Ξ±\n hom_inv : hom (inv x) ≑ x\n inv_hom : inv (hom x) ≑ x" }, { "name": "Iris.OFE._inst_Iso", "content": "instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.hom := iso.hom.ne" }, { "name": "Iris.OFE._inst_Iso", "content": "instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.inv := iso.inv.ne" }, { "name": "Iris.OFE.Iso.symm", "content": "def Iso.symm [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : Iso Ξ² Ξ± where\n hom := iso.inv\n inv := iso.hom\n hom_inv := by admit /- proof elided -/" }, { "name": "Iris.Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "Iris.IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Iris.LeibnizO", "content": "@[ext] structure LeibnizO (Ξ± : Type _) where\n car : Ξ±" }, { "name": "Iris.optionChain", "content": "def optionChain (c : Chain (Option Ξ±)) (x : Ξ±) : Chain Ξ± :=" }, { "name": "Iris.isCOFE_option", "content": "instance isCOFE_option [IsCOFE Ξ±] : IsCOFE (Option Ξ±) where\n compl c := (c 0).map fun x => IsCOFE.compl (optionChain c x)\n conv_compl {n} c := by admit /- proof elided -/" }, { "name": "Iris.Fixpoint.chain", "content": "def Fixpoint.chain [OFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Chain Ξ± where\n chain n := Nat.repeat f (n + 1) default\n cauchy {n} := by admit /- proof elided -/" }, { "name": "Iris.fixpoint", "content": "def fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Ξ± :=\n COFE.compl <| Fixpoint.chain f\n\nnonrec abbrev OFE.ContractiveHom.fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) : Ξ± := fixpoint f.f" } ]
[ { "name": "Iris.OFE.Dist.lt", "content": "theorem Dist.lt [OFE Ξ±] {m n} {x y : Ξ±} : x ≑{n}≑ y β†’ m < n β†’ x ≑{m}≑ y" }, { "name": "Iris.OFE.Dist.le", "content": "theorem Dist.le [OFE Ξ±] {m n} {x y : Ξ±} (h : x ≑{n}≑ y) (h' : m ≀ n) : x ≑{m}≑ y" }, { "name": "Iris.OFE.Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "Iris.OFE.Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Iris.OFE.Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "Iris.OFE.equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Iris.OFE.Equiv.symm", "content": "@[symm] theorem Equiv.symm [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ x" }, { "name": "Iris.OFE.DistLater.symm", "content": "@[symm] theorem DistLater.symm [OFE Ξ±] {n} {x : Ξ±} (h : DistLater n x y) : DistLater n y x" }, { "name": "Iris.OFE.distLater_zero", "content": "@[simp] theorem distLater_zero [OFE Ξ±] {x y : Ξ±} : DistLater 0 x y" }, { "name": "Iris.OFE.distLater_succ", "content": "theorem distLater_succ [OFE Ξ±] {n} {x y : Ξ±} : DistLater n.succ x y ↔ x ≑{n}≑ y" }, { "name": "Iris.OFE.Contractive.zero", "content": "@[simp] theorem Contractive.zero [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] {x y} :\n f x ≑{0}≑ f y" }, { "name": "Iris.OFE.Contractive.succ", "content": "theorem Contractive.succ [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] {n x y}\n (h : x ≑{n}≑ y) : f x ≑{n.succ}≑ f y" } ]
namespace Iris class OFE (Ξ± : Type _) where Equiv : Ξ± β†’ Ξ± β†’ Prop Dist : Nat β†’ Ξ± β†’ Ξ± β†’ Prop dist_eqv : Equivalence (Dist n) equiv_dist : Equiv x y ↔ βˆ€ n, Dist n x y dist_lt : Dist n x y β†’ m < n β†’ Dist m x y open OFE scoped infix:40 " ≑ " => OFE.Equiv scoped notation:40 x " ≑{" n "}≑ " y:41 => OFE.Dist n x y namespace OFE class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚ instance id_ne [OFE Ξ±] : NonExpansive (@id Ξ±) := ⟨fun _ _ _ h => h⟩ class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚ def DistLater [OFE Ξ±] (n : Nat) (x y : Ξ±) : Prop := βˆ€ m, m < n β†’ x ≑{m}≑ y class Contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where distLater_dist : DistLater n x y β†’ f x ≑{n}≑ f y instance ne_of_contractive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) [Contractive f] : NonExpansive f where ne := fun _ _ _ h => Contractive.distLater_dist (Dist.distLater h) instance [OFE Ξ±] [OFE Ξ²] {x : Ξ²} : Contractive (fun _ : Ξ± => x) where distLater_dist := fun _ => Dist.rfl @[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where f : Ξ± β†’ Ξ² ne : NonExpansive f @[inherit_doc] infixr:25 " -n> " => Hom instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -n> Ξ²) : NonExpansive f := f.ne @[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where [contractive : Contractive f] ne := ne_of_contractive f infixr:25 " -c> " => ContractiveHom instance [OFE Ξ±] [OFE Ξ²] (f : Ξ± -c> Ξ²) : Contractive f := f.contractive instance : OFE Unit where Equiv _ _ := True Dist _ _ _ := True dist_eqv := ⟨fun _ => ⟨⟩, id, fun _ => id⟩ equiv_dist := by admit /- proof elided -/ instance [OFE Ξ±] : OFE (ULift Ξ±) where Equiv x y := x.down ≑ y.down Dist n x y := x.down ≑{n}≑ y.down dist_eqv := InvImage.equivalence dist_eqv equiv_dist := equiv_dist dist_lt := dist_lt instance [OFE Ξ±] : OFE (Option Ξ±) where Equiv := Option.Forallβ‚‚ Equiv Dist n := Option.Forallβ‚‚ (Dist n) dist_eqv := Option.Forallβ‚‚.equivalence dist_eqv equiv_dist {x y} := by admit /- proof elided -/ instance [OFE Ξ±] [OFE.Discrete Ξ±] : OFE.Discrete (Option Ξ±) where discrete_0 {mx my} e := match mx, my with | none, none => e | none, some _ => e | some _, none => e | some x, some y => show x ≑ y from discrete_0 e instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩ instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] : NonExpansiveβ‚‚ (Option.merge op) where ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/ instance [OFEFun (Ξ² : Ξ± β†’ _)] : OFE ((x : Ξ±) β†’ Ξ² x) where Equiv f g := βˆ€ x, f x ≑ g x Dist n f g := βˆ€ x, f x ≑{n}≑ g x dist_eqv := { refl _ _ := dist_eqv.refl _ symm h _ := dist_eqv.symm (h _) trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _) } equiv_dist {_ _} := by admit /- proof elided -/ instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -n> Ξ²) where Equiv f g := f.f ≑ g.f Dist n f g := f.f ≑{n}≑ g.f dist_eqv := { refl _ := dist_eqv.refl _ symm h := dist_eqv.symm h trans h1 h2 := dist_eqv.trans h1 h2 } equiv_dist := equiv_dist dist_lt := dist_lt instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± -c> Ξ²) where Equiv f g := Equiv f.toHom g.toHom Dist n f g := Dist n f.toHom g.toHom dist_eqv := { refl _ := dist_eqv.refl _ symm h := dist_eqv.symm h trans h1 h2 := dist_eqv.trans h1 h2 } equiv_dist := equiv_dist dist_lt := dist_lt instance [OFE Ξ±] [OFE Ξ²] : OFE (Ξ± Γ— Ξ²) where Equiv a b := a.1 ≑ b.1 ∧ a.2 ≑ b.2 Dist n a b := a.1 ≑{n}≑ b.1 ∧ a.2 ≑{n}≑ b.2 dist_eqv := { refl _ := ⟨dist_eqv.refl _, dist_eqv.refl _⟩ symm h := ⟨dist_eqv.symm h.1, dist_eqv.symm h.2⟩ trans h1 h2 := ⟨dist_eqv.trans h1.1 h2.1, dist_eqv.trans h1.2 h2.2⟩ } equiv_dist {_ _} := by admit /- proof elided -/ @[ext] structure Iso (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where hom : Ξ± -n> Ξ² inv : Ξ² -n> Ξ± hom_inv : hom (inv x) ≑ x inv_hom : inv (hom x) ≑ x instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.hom := iso.hom.ne instance [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : NonExpansive iso.inv := iso.inv.ne def Iso.symm [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : Iso Ξ² Ξ± where hom := iso.inv inv := iso.hom hom_inv := by admit /- proof elided -/ end OFE structure Chain (Ξ± : Type _) [OFE Ξ±] where chain : Nat β†’ Ξ± cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n namespace Chain end Chain class IsCOFE (Ξ± : Type _) [OFE Ξ±] where compl : Chain Ξ± β†’ Ξ± conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n namespace COFE end COFE @[ext] structure LeibnizO (Ξ± : Type _) where car : Ξ± section DiscreteFunOF open COFE end DiscreteFunOF section Option variable [OFE Ξ±] def optionChain (c : Chain (Option Ξ±)) (x : Ξ±) : Chain Ξ± := instance isCOFE_option [IsCOFE Ξ±] : IsCOFE (Option Ξ±) where compl c := (c 0).map fun x => IsCOFE.compl (optionChain c x) conv_compl {n} c := by admit /- proof elided -/ end Option section OptionOF open COFE variable (F : OFunctorPre) end OptionOF section Fixpoint def Fixpoint.chain [OFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Chain Ξ± where chain n := Nat.repeat f (n + 1) default cauchy {n} := by admit /- proof elided -/ def fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± β†’ Ξ±) [Contractive f] : Ξ± := COFE.compl <| Fixpoint.chain f nonrec abbrev OFE.ContractiveHom.fixpoint [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) : Ξ± := fixpoint f.f
theorem fixpoint_unfold [COFE Ξ±] [Inhabited Ξ±] (f : Ξ± -c> Ξ±) : fixpoint f ≑ f (fixpoint f) :=
:= by refine equiv_dist.mpr fun n => ?_ apply COFE.conv_compl.trans refine .trans ?_ (NonExpansive.ne COFE.conv_compl.symm) induction n with | zero => exact Contractive.zero f.f | succ _ IH => exact (Contractive.succ f.f IH.symm).symm
4
41
false
Framework
233
Iris.BI.loeb
theorem loeb [BI PROP] [BILoeb PROP] {P : PROP} : (β–· P β†’ P) ⊒ P
iris-lean
src/Iris/BI/DerivedLaws.lean
[ "import Iris.BI.Extensions", "import Iris.Std.TC", "import Iris.Std.Classes", "import Iris.BI.BI", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import Iris.BI.Classes", "import Iris.Std.Rewrite" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Function.const", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term\n\nsyntax:max \"<affine> \" term:40 : term\n\nsyntax:max \"β–‘ \" term:40 : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "BILoeb", "content": "class BILoeb (PROP : Type _) [BI PROP] where\n loeb_weak {P : PROP} : (β–· P ⊒ P) β†’ True ⊒ P" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" } ]
[]
[ { "name": "Iris.BI.and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_symm", "content": "theorem and_symm [BI PROP] {P Q : PROP} : P ∧ Q ⊒ Q ∧ P" }, { "name": "Iris.BI.imp_intro'", "content": "theorem imp_intro' [BI PROP] {P Q R : PROP} (h : Q ∧ P ⊒ R) : P ⊒ Q β†’ R" }, { "name": "Iris.BI.imp_elim'", "content": "theorem imp_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P β†’ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.imp_elim_l", "content": "theorem imp_elim_l [BI PROP] {P Q : PROP} : (P β†’ Q) ∧ P ⊒ Q" }, { "name": "Iris.BI.imp_elim_r", "content": "theorem imp_elim_r [BI PROP] {P Q : PROP} : P ∧ (P β†’ Q) ⊒ Q" }, { "name": "Iris.BI.true_intro", "content": "theorem true_intro [BI PROP] {P : PROP} : P ⊒ True" }, { "name": "Iris.BI.and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "Iris.BI.and_mono_l", "content": "theorem and_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P ∧ Q ⊒ P' ∧ Q" }, { "name": "Iris.BI.and_mono_r", "content": "theorem and_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P ∧ Q ⊒ P ∧ Q'" }, { "name": "Iris.BI.and_self", "content": "theorem and_self [BI PROP] {P : PROP} : P ∧ P ⊣⊒ P" }, { "name": "Iris.BI.and_comm", "content": "theorem and_comm [BI PROP] {P Q : PROP} : P ∧ Q ⊣⊒ Q ∧ P" }, { "name": "Iris.BI.and_assoc", "content": "theorem and_assoc [BI PROP] {P Q R : PROP} : (P ∧ Q) ∧ R ⊣⊒ P ∧ Q ∧ R" }, { "name": "Iris.BI.pure_elim", "content": "theorem pure_elim [BI PROP] (Ο† : Prop) {Q R : PROP} (h1 : Q ⊒ βŒœΟ†βŒ) (h2 : Ο† β†’ Q ⊒ R) : Q ⊒ R" }, { "name": "Iris.BI.pure_elim_l", "content": "theorem pure_elim_l [BI PROP] {Ο† : Prop} {Q R : PROP} (h : Ο† β†’ Q ⊒ R) : βŒœΟ†βŒ ∧ Q ⊒ R" }, { "name": "Iris.BI.pure_elim_r", "content": "theorem pure_elim_r [BI PROP] {Ο† : Prop} {Q R : PROP} (h : Ο† β†’ Q ⊒ R) : Q ∧ βŒœΟ†βŒ ⊒ R" }, { "name": "Iris.BI.later_impl", "content": "theorem later_impl [BI PROP] {P Q : PROP} : β–· (P β†’ Q) ⊒ β–· P β†’ β–· Q" }, { "name": "Iris.BI.entails_impl_true", "content": "theorem entails_impl_true [BI PROP] {P Q : PROP} :\n (P ⊒ Q) ↔ iprop((True : PROP) ⊒ (P β†’ Q))" } ]
import Iris.BI.Classes import Iris.BI.Extensions import Iris.BI.BI import Iris.Std.Classes import Iris.Std.Rewrite import Iris.Std.TC namespace Iris.BI open Iris.Std BI
theorem loeb [BI PROP] [BILoeb PROP] {P : PROP} : (β–· P β†’ P) ⊒ P :=
:= by apply entails_impl_true.mpr apply BILoeb.loeb_weak apply imp_intro apply (and_mono .rfl and_self.mpr).trans apply (and_mono .rfl (and_mono later_intro .rfl)).trans apply (and_mono later_impl .rfl).trans apply and_assoc.mpr.trans apply (and_mono imp_elim_l .rfl).trans exact imp_elim_r
7
68
false
Framework
234
Iris.BI.plainly_and_sep
theorem plainly_and_sep : β–  (P ∧ Q) ⊒ β–  (P βˆ— Q)
iris-lean
src/Iris/BI/Plainly.lean
[ "import Iris.Algebra", "import src.Iris.BI.DerivedLaws", "import src/Iris/Instances/UPred/Instance.lean", "import Iris.BI.DerivedLaws", "import Iris.BI.BI", "import src.Iris.BI.BI", "import Iris.BI.Classes" ]
[ { "name": "Lean.MonadQuotation", "module": "Init.Prelude" }, { "name": "Lean.MonadRef", "module": "Init.Prelude" }, { "name": "Monad", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "syntax term:26 \" ==βˆ— \" term:25 : term", "content": "syntax term:26 \" ==βˆ— \" term:25 : term\n\nsyntax term \"={ \" term \" , \" term \" }=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }[ \" term \" ]β–·=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }β–·=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }[ \" term \" ]β–·^\" term \"=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }β–·^\" term \"=βˆ— \" term : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term" }, { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term\n\nsyntax \"β–  \" term:40 : term" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|==> $P)) => ``(BUpd.bupd iprop($P))\n | `(iprop($P ==βˆ— $Q)) => ``(BIBase.wand iprop($P) (BUpd.bupd iprop($Q)))\n\ndelab_rule BUpd.bupd\n | `($_ $P) => do ``(iprop(|==> $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 , $E2 }=> $P)) => ``(FUpd.fupd $E1 $E2 iprop($P))\n | `(iprop($P ={ $E1 , $E2 }=βˆ— $Q)) => ``(BIBase.wand iprop($P) (FUpd.fupd $E1 $E2 iprop($Q)))\n | `(iprop(|={ $E1 }=> $P)) => ``(FUpd.fupd $E1 $E1 iprop($P))\n | `(iprop($P ={ $E1 }=βˆ— $Q)) => ``(BIBase.wand iprop($P) (FUpd.fupd $E1 $E1 iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 }[ $E2 ]β–·=> $P)) => ``(iprop(|={$E1, $E2}=> β–· (|={ $E2, $E1 }=> iprop($P))))\n | `(iprop($P ={ $E1 }[ $E2 ]β–·=βˆ— $Q)) => ``(iprop(iprop($P) -βˆ— |={$E1}[$E2]β–·=> iprop($Q)))\n | `(iprop(|={ $E1 }β–·=> $P)) => ``(iprop(|={$E1}[$E1]β–·=> iprop($P)))\n | `(iprop($P ={ $E1 }β–·=βˆ— $Q)) => ``(iprop(iprop($P) ={$E1}[$E1]β–·=βˆ— iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 }[ $E2 ]β–·^$n=> $P)) => ``(iprop(|={$E1, $E2}=> β–·^[$n] (|={ $E2, $E1 }=> iprop($P))))\n | `(iprop($P ={ $E1 }[ $E2 ]β–·^$n=βˆ— $Q)) => ``(iprop(iprop($P) -βˆ— |={$E1}[$E2]β–·^$n=> iprop($Q)))\n | `(iprop(|={ $E1 }β–·^$n=> $P)) => ``(iprop(|={$E1}[$E1]β–·^$n=> iprop($P)))\n | `(iprop($P ={ $E1 }β–·^$n=βˆ— $Q)) => ``(iprop(iprop($P) ={$E1}[$E1]β–·^$n=βˆ— iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–  $P)) => ``(Plainly.plainly iprop($P))\n\ndelab_rule Plainly.plainly\n | `($_ $P) => do ``(iprop(β–  $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β– ? $p $P)) => ``(Plainly.plainlyIf $p iprop($P))\n\ndelab_rule Plainly.plainlyIf\n | `($_ $p $P) => do ``(iprop(β– ? $p $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "unpackIprop", "content": "partial def unpackIprop [Monad m] [MonadRef m] [MonadQuotation m] : Term β†’ m Term\n | `(iprop($P)) => do `($P)\n | `($P:ident) => do `($P)\n | `(?$P:ident) => do `(?$P)\n | `(($P)) => do `(($(← unpackIprop P)))\n | `($P $[ $Q]*) => do ``($P $[ $Q]*)\n | `(if $c then $t else $e) => do\n let t ← unpackIprop t\n let e ← unpackIprop e\n `(if $c then $t else $e)\n | `(($P : $t)) => do ``(($(← unpackIprop P) : $t))\n | `($t) => `($t:term)" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "Idempotent", "content": "class Idempotent (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n idem {x : Ξ±} : R (f x x) x" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "", "content": "instance : BIPlainly (UPred M) where\n mono H _ _ _ := H _ _ CMRA.unit_validN\n elim_persistently {P} n x Hx := by admit /- proof elided -/" }, { "name": "persistently", "content": "protected def persistently (P : UPred M) : UPred M where\n holds n x := P n (CMRA.core x)\n mono H Hx Hn := P.mono H (CMRA.core_incN_core Hx) Hn" }, { "name": "BIUpdate", "content": "class BIUpdate (PROP : Type _) [BI PROP] extends BUpd PROP where\n [bupd_ne : OFE.NonExpansive (BUpd.bupd (PROP := PROP))]\n intro {P : PROP} : iprop(P ⊒ |==> P)\n mono {P Q : PROP} : iprop(P ⊒ Q) β†’ iprop(|==> P ⊒ |==> Q)\n trans {P : PROP} : iprop(|==> |==> P ⊒ |==> P)\n frame_r {P R : PROP} : iprop((|==> P) βˆ— R ⊒ |==> (P βˆ— R))" }, { "name": "UPred", "content": "@[ext]\nstructure UPred (M : Type _) [UCMRA M] where\n holds : Nat β†’ M β†’ Prop\n mono {n1 n2 x1 x2} : holds n1 x1 β†’ x1 β‰Ό{n2} x2 β†’ n2 ≀ n1 β†’ holds n2 x2" }, { "name": "IsModal", "content": "class IsModal [BI PROP1] [BI PROP2] (M : PROP1 β†’ PROP2)\n (iaction saction : ModalityAction PROP1 PROP2) where\n spec_intuitionistic : iaction.intuitionistic_action_spec M\n spec_spatial : saction.spatial_action_spec M\n emp : iprop(emp) ⊒ M iprop(emp)\n mono : βˆ€ {P Q}, (P ⊒ Q) β†’ M P ⊒ M Q\n sep : βˆ€ {P Q}, iprop(M P βˆ— M Q) ⊒ M iprop(P βˆ— Q)" }, { "name": "core", "content": "def core (x : Ξ±) := (pcore x).getD x" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "UCMRA", "content": "class UCMRA (Ξ± : Type _) extends CMRA Ξ± where\n unit : Ξ±\n unit_valid : βœ“ unit\n unit_left_id : unit β€’ x ≑ x\n pcore_unit : pcore unit ≑ some unit" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "plainly", "content": "protected def plainly (P : UPred M) : UPred M where\n holds n _ := P n UCMRA.unit\n mono H _ Hn := P.mono H (CMRA.incN_refl UCMRA.unit) Hn" }, { "name": "BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "", "content": "instance : BIPlainlyExists (UPred M) where\n plainly_sExists_1 _ _ _ := fun ⟨_, hp⟩ => ⟨_, ⟨_, rfl⟩, hp⟩" }, { "name": "BIPlainlyExists", "content": "class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where\n plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p" }, { "name": "", "content": "instance : Plainly (UPred M) := ⟨UPred.plainly⟩" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "persistently_and_sep_assoc", "content": "theorem persistently_and_sep_assoc [BI PROP] {P Q R : PROP} :\n <pers> P ∧ (Q βˆ— R) ⊣⊒ (<pers> P ∧ Q) βˆ— R" }, { "name": "and_mono_l", "content": "theorem and_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P ∧ Q ⊒ P' ∧ Q" }, { "name": "and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" }, { "name": "and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "sep_assoc", "content": "theorem sep_assoc [BI PROP] {P Q R : PROP} : (P βˆ— Q) βˆ— R ⊣⊒ P βˆ— Q βˆ— R" }, { "name": "sep_congr_l", "content": "theorem sep_congr_l [BI PROP] {P P' Q : PROP} (h : P ⊣⊒ P') : P βˆ— Q ⊣⊒ P' βˆ— Q" }, { "name": "sep_congr", "content": "@[rw_mono_rule]\ntheorem sep_congr [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊣⊒ Q) (h2 : P' ⊣⊒ Q') :\n (P βˆ— P') ⊣⊒ (Q βˆ— Q')" }, { "name": "sep_congr_r", "content": "theorem sep_congr_r [BI PROP] {P Q Q' : PROP} (h : Q ⊣⊒ Q') : P βˆ— Q ⊣⊒ P βˆ— Q'" }, { "name": "sep_mono_l", "content": "theorem sep_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P βˆ— Q ⊒ P' βˆ— Q" }, { "name": "BIBase.Entails.rfl", "content": "@[simp] theorem BIBase.Entails.rfl [BI PROP] {P : PROP} : P ⊒ P" }, { "name": "imp_intro'", "content": "theorem imp_intro' [BI PROP] {P Q R : PROP} (h : Q ∧ P ⊒ R) : P ⊒ Q β†’ R" }, { "name": "and_comm", "content": "theorem and_comm [BI PROP] {P Q : PROP} : P ∧ Q ⊣⊒ Q ∧ P" }, { "name": "and_symm", "content": "theorem and_symm [BI PROP] {P Q : PROP} : P ∧ Q ⊒ Q ∧ P" }, { "name": "imp_elim'", "content": "theorem imp_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P β†’ R) : P ∧ Q ⊒ R" }, { "name": "pure_elim", "content": "theorem pure_elim [BI PROP] (Ο† : Prop) {Q R : PROP} (h1 : Q ⊒ βŒœΟ†βŒ) (h2 : Ο† β†’ Q ⊒ R) : Q ⊒ R" }, { "name": "and_self", "content": "theorem and_self [BI PROP] {P : PROP} : P ∧ P ⊣⊒ P" }, { "name": "forall_intro", "content": "theorem forall_intro [BI PROP] {P : PROP} {Ξ¨ : Ξ± β†’ PROP} (h : βˆ€ a, P ⊒ Ξ¨ a) : P ⊒ βˆ€ a, Ξ¨ a" }, { "name": "forall_elim", "content": "theorem forall_elim [BI PROP] {Ξ¨ : Ξ± β†’ PROP} (a : Ξ±) : (βˆ€ a, Ξ¨ a) ⊒ Ξ¨ a" }, { "name": "forall_mono", "content": "@[rw_mono_rule]\ntheorem forall_mono [BI PROP] {Ξ¦ Ξ¨ : Ξ± β†’ PROP} (h : βˆ€ a, Ξ¦ a ⊒ Ξ¨ a) : (βˆ€ a, Ξ¦ a) ⊒ βˆ€ a, Ξ¨ a" }, { "name": "and_forall_bool", "content": "theorem and_forall_bool [BI PROP] {P Q : PROP} :\n P ∧ Q ⊣⊒ Β«forallΒ» (fun b : Bool => if b then P else Q)" }, { "name": "persistently_and_emp_elim", "content": "theorem persistently_and_emp_elim {P : PROP} [BI PROP] : emp ∧ <pers> P ⊒ P" }, { "name": "sep_emp", "content": "theorem sep_emp [BI PROP] {P : PROP} : P βˆ— emp ⊣⊒ P" } ]
[ { "name": "Iris.Plainly", "content": "class Plainly (PROP : Type _) where\n plainly : PROP β†’ PROP" }, { "name": "Iris.Plainly.plainlyIf", "content": "def Plainly.plainlyIf [Iris.BI.BIBase PROP] [Plainly PROP] (p : Bool) (P : PROP) : PROP :=\n iprop(if p then β–  P else P)" }, { "name": "Iris.BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "Iris.BIPlainlyExists", "content": "class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where\n plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p" } ]
[ { "name": "Iris.BI.persistently_elim_plainly", "content": "theorem persistently_elim_plainly : <pers> β–  P ⊣⊒ β–  P" }, { "name": "Iris.BI.plainly_forall_2", "content": "theorem plainly_forall_2 {Ξ¨ : Ξ± β†’ PROP} : (βˆ€ a, β–  (Ξ¨ a)) ⊒ β–  (βˆ€ a, Ξ¨ a)" }, { "name": "Iris.BI.plainly_and_sep_assoc", "content": "theorem plainly_and_sep_assoc : β–  P ∧ (Q βˆ— R) ⊣⊒ (β–  P ∧ Q) βˆ— R" }, { "name": "Iris.BI.plainly_and_emp_elim", "content": "theorem plainly_and_emp_elim : emp ∧ β–  P ⊒ P" }, { "name": "Iris.BI.plainly_forall", "content": "theorem plainly_forall {Ξ¨ : Ξ± β†’ PROP} : β–  (βˆ€ a, Ξ¨ a) ⊣⊒ βˆ€ a, β–  (Ξ¨ a)" }, { "name": "Iris.BI.plainly_and", "content": "theorem plainly_and : β–  (P ∧ Q) ⊣⊒ β–  P ∧ β–  Q" } ]
import Iris.BI.Classes import Iris.BI.BI import Iris.BI.DerivedLaws import Iris.Algebra namespace Iris open BI class Plainly (PROP : Type _) where plainly : PROP β†’ PROP def Plainly.plainlyIf [Iris.BI.BIBase PROP] [Plainly PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–  P else P) class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))] mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q elim_persistently {P : PROP} : β–  P ⊒ <pers> P idem {P : PROP} : β–  P ⊒ β–  β–  P plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦ plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q) emp_intro {P : PROP} : P ⊒ β–  emp plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p namespace BI open Iris.Std section PlainlyLaws open BIPlainly variable [BI PROP] [BIPlainly PROP] variable {P Q R : PROP}
theorem plainly_and_sep : β–  (P ∧ Q) ⊒ β–  (P βˆ— Q) :=
:= by refine (plainly_and.mp.trans <| (and_mono idem .rfl).trans plainly_and.mpr).trans ?_ refine (mono <| and_mono .rfl emp_sep.mpr).trans ?_ refine (mono <| plainly_and_sep_assoc.1).trans ?_ refine (mono <| sep_mono and_comm.mp .rfl).trans ?_ exact (mono <| sep_mono plainly_and_emp_elim .rfl).trans .rfl
6
55
false
Framework
235
Iris.BI.later_exists_false
theorem later_exists_false [BI PROP] {Ξ¦ : Ξ± β†’ PROP} : (β–· βˆƒ a, Ξ¦ a) ⊒ β–· False ∨ βˆƒ a, β–· Ξ¦ a
iris-lean
src/Iris/BI/DerivedLaws.lean
[ "import Iris.BI.Extensions", "import Iris.Std.TC", "import Iris.Std.Classes", "import Iris.BI.BI", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import Iris.BI.Classes", "import Iris.Std.Rewrite" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term\n\nsyntax:max \"<affine> \" term:40 : term\n\nsyntax:max \"β–‘ \" term:40 : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" } ]
[]
[ { "name": "Iris.BI.or_intro_r'", "content": "theorem or_intro_r' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ⊒ Q ∨ R" }, { "name": "Iris.BI.imp_intro'", "content": "theorem imp_intro' [BI PROP] {P Q R : PROP} (h : Q ∧ P ⊒ R) : P ⊒ Q β†’ R" }, { "name": "Iris.BI.exists_intro", "content": "theorem exists_intro [BI PROP] {Ξ¨ : Ξ± β†’ PROP} (a : Ξ±) : Ξ¨ a ⊒ βˆƒ a, Ξ¨ a" }, { "name": "Iris.BI.exists_elim", "content": "theorem exists_elim [BI PROP] {Ξ¦ : Ξ± β†’ PROP} {Q : PROP} (h : βˆ€ a, Ξ¦ a ⊒ Q) : (βˆƒ a, Ξ¦ a) ⊒ Q" }, { "name": "Iris.BI.exists_intro'", "content": "theorem exists_intro' [BI PROP] {P : PROP} {Ξ¨ : Ξ± β†’ PROP} (a : Ξ±) (h : P ⊒ Ξ¨ a) : P ⊒ βˆƒ a, Ξ¨ a" } ]
import Iris.BI.Classes import Iris.BI.Extensions import Iris.BI.BI import Iris.Std.Classes import Iris.Std.Rewrite import Iris.Std.TC namespace Iris.BI open Iris.Std BI
theorem later_exists_false [BI PROP] {Ξ¦ : Ξ± β†’ PROP} : (β–· βˆƒ a, Ξ¦ a) ⊒ β–· False ∨ βˆƒ a, β–· Ξ¦ a :=
:= by apply later_sExists_false.trans apply or_elim · apply or_intro_l · refine or_intro_r' <| exists_elim ?_ intro P refine imp_elim <| pure_elim' ?_ rintro ⟨a, rfl⟩ exact imp_intro' <| exists_intro' a and_elim_l
4
52
false
Framework
236
Iris.DFrac.update_discard
theorem DFrac.update_discard {dq : DFrac F} : dq ~~> .discard
iris-lean
src/Iris/Algebra/DFrac.lean
[ "import Iris.Algebra.CMRA", "import Iris.Algebra.Updates", "import src.Iris.Algebra.Frac", "import Iris.Algebra.OFE", "import Iris.Algebra.LocalUpdates", "import src.Iris.Algebra.CMRA", "import Iris.Algebra.Frac" ]
[ { "name": "Add", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x", "content": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x" }, { "name": "Fractional", "content": "def Fractional [Fraction Ξ±] (a : Ξ±) : Prop := βˆƒ b, Proper (a + b)" }, { "name": "Fraction", "content": "class Fraction (Ξ± : Type _) extends Add Ξ± where\n \n Proper : Ξ± β†’ Prop\n add_comm : βˆ€ a b : Ξ±, a + b = b + a\n add_assoc : βˆ€ a b c : Ξ±, a + (b + c) = (a + b) + c\n add_left_cancel : βˆ€ {a b c : Ξ±}, a + b = a + c β†’ b = c\n \n add_ne : βˆ€ {a b : Ξ±}, a β‰  b + a\n proper_add_mono_left : βˆ€ {a b : Ξ±}, Proper (a + b) β†’ Proper a" }, { "name": "NumericFraction", "content": "class NumericFraction (Ξ± : Type _) extends One Ξ±, Add Ξ±, LE Ξ±, LT Ξ± where\n add_comm : βˆ€ a b : Ξ±, a + b = b + a\n add_assoc : βˆ€ a b c : Ξ±, a + (b + c) = (a + b) + c\n add_left_cancel : βˆ€ {a b c : Ξ±}, a + b = a + c β†’ b = c\n le_def : βˆ€ {a b : Ξ±}, a ≀ b ↔ a = b ∨ a < b\n lt_def : βˆ€ {a b : Ξ±}, a < b ↔ βˆƒ c : Ξ±, a + c = b\n lt_irrefl : βˆ€ {a : Ξ±}, Β¬a < a" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "Update", "content": "def Update [CMRA Ξ±] (x y : Ξ±) := βˆ€ n mz,\n βœ“{n} (x β€’? mz) β†’ βœ“{n} (y β€’? mz)" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "op?", "content": "def op? [CMRA Ξ±] (x : Ξ±) : Option Ξ± β†’ Ξ±\n | some y => x β€’ y\n | none => x" }, { "name": "Discrete", "content": "class Discrete (Ξ± : Type _) [CMRA Ξ±] extends OFE.Discrete Ξ± where\n discrete_valid {x : Ξ±} : βœ“{0} x β†’ βœ“ x" }, { "name": "Discrete", "content": "class Discrete (Ξ± : Type _) [OFE Ξ±] where\n discrete_0 {x y : Ξ±} : x ≑{0}≑ y β†’ x ≑ y" }, { "name": "infixr:50 \" ~~> \" => Update", "content": "infixr:50 \" ~~> \" => Update" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "infix:60 \" β€’? \" => op?", "content": "infix:60 \" β€’? \" => op?" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Fractional.of_add_right", "content": "theorem Fractional.of_add_right {a a' : Ξ±} (H : Fractional (a + a')) : Fractional a'" }, { "name": "valid_iff_validN'", "content": "theorem valid_iff_validN' [Discrete Ξ±] (n) {x : Ξ±} : βœ“ x ↔ βœ“{n} x" }, { "name": "validN_of_le", "content": "theorem validN_of_le {n n'} {x : Ξ±} : n' ≀ n β†’ βœ“{n} x β†’ βœ“{n'} x" }, { "name": "Valid.validN", "content": "theorem Valid.validN : βœ“ (x : Ξ±) β†’ βœ“{n} x" } ]
[ { "name": "Iris.DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "Iris.valid", "content": "def valid : DFrac F β†’ Prop\n | .own f => Proper f\n | .discard => True\n | .ownDiscard f => Fractional f" }, { "name": "Iris.pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "Iris.op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" } ]
[ { "name": "Iris.valid_op_own", "content": "theorem valid_op_own {dq : DFrac F} {q : F} : βœ“ dq β€’ own q β†’ Fractional q" } ]
import Iris.Algebra.CMRA import Iris.Algebra.OFE import Iris.Algebra.Frac import Iris.Algebra.Updates import Iris.Algebra.LocalUpdates namespace Iris inductive DFrac (F : Type _) where | own (f : F) : DFrac F | discard : DFrac F | ownDiscard (f : F) : DFrac F section dfrac open DFrac Fraction OFE.Discrete variable [UFraction F] def valid : DFrac F β†’ Prop | .own f => Proper f | .discard => True | .ownDiscard f => Fractional f def pcore : DFrac F β†’ Option (DFrac F) | own _ => none | .discard => some discard | ownDiscard _ => some discard def op : DFrac F β†’ DFrac F β†’ DFrac F | .discard, .discard => discard | own f, .discard | ownDiscard f, .discard | .discard, own f | .discard, ownDiscard f => ownDiscard f | own f, own f' => own (f + f') | own f, ownDiscard f' | ownDiscard f, own f' | ownDiscard f, ownDiscard f' => ownDiscard (f + f')
theorem DFrac.update_discard {dq : DFrac F} : dq ~~> .discard :=
:= by intros n q H apply (CMRA.valid_iff_validN' n).mp have H' := (CMRA.valid_iff_validN' n).mpr H simp [CMRA.op?] at H' ⊒ rcases q with (_|⟨q|_|q⟩) <;> simp [CMRA.Valid, valid, CMRA.op, op] · cases dq <;> first | exact valid_op_own H | exact H · cases dq <;> first | exact Fractional.of_add_right H | exact H
3
31
false
Framework
237
Iris.local_update_unital_discrete
theorem local_update_unital_discrete [CMRA.Discrete Ξ±] (x y x' y' : Ξ±) : (x, y) ~l~> (x', y') ↔ βˆ€ z, βœ“ x β†’ x ≑ y β€’ z β†’ (βœ“ x' ∧ x' ≑ y' β€’ z)
iris-lean
src/Iris/Algebra/LocalUpdates.lean
[ "import Iris.Algebra.CMRA", "import src.Iris.Algebra.CMRA", "import src.Iris.Algebra.OFE" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x", "content": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "Discrete", "content": "class Discrete (Ξ± : Type _) [CMRA Ξ±] extends OFE.Discrete Ξ± where\n discrete_valid {x : Ξ±} : βœ“{0} x β†’ βœ“ x" }, { "name": "Discrete", "content": "class Discrete (Ξ± : Type _) [OFE Ξ±] where\n discrete_0 {x y : Ξ±} : x ≑{0}≑ y β†’ x ≑ y" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "UCMRA", "content": "class UCMRA (Ξ± : Type _) extends CMRA Ξ± where\n unit : Ξ±\n unit_valid : βœ“ unit\n unit_left_id : unit β€’ x ≑ x\n pcore_unit : pcore unit ≑ some unit" }, { "name": "Iso.symm", "content": "def Iso.symm [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : Iso Ξ² Ξ± where\n hom := iso.inv\n inv := iso.hom\n hom_inv := by admit /- proof elided -/" }, { "name": "Iso", "content": "@[ext] structure Iso (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n hom : Ξ± -n> Ξ²\n inv : Ξ² -n> Ξ±\n hom_inv : hom (inv x) ≑ x\n inv_hom : inv (hom x) ≑ x" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "Included.trans", "content": "theorem Included.trans : (x : Ξ±) β‰Ό y β†’ y β‰Ό z β†’ x β‰Ό z" }, { "name": "inc_trans", "content": "theorem inc_trans {x y z : Ξ±} : x β‰Ό y β†’ y β‰Ό z β†’ x β‰Ό z" }, { "name": "op_left_eqv", "content": "theorem op_left_eqv {x y : Ξ±} (z : Ξ±) (e : x ≑ y) : x β€’ z ≑ y β€’ z" }, { "name": "_root_.Iris.OFE.Dist.op_r", "content": "theorem _root_.Iris.OFE.Dist.op_r {x y z : Ξ±} : y ≑{n}≑ z β†’ x β€’ y ≑{n}≑ x β€’ z" }, { "name": "op_right_dist", "content": "theorem op_right_dist (x : Ξ±) {y z : Ξ±} (e : y ≑{n}≑ z) : x β€’ y ≑{n}≑ x β€’ z" }, { "name": "_root_.Iris.OFE.Equiv.op_r", "content": "theorem _root_.Iris.OFE.Equiv.op_r {x y z : Ξ±} : y ≑ z β†’ x β€’ y ≑ x β€’ z" }, { "name": "op_right_eqv", "content": "theorem op_right_eqv (x : Ξ±) {y z : Ξ±} (e : y ≑ z) : x β€’ y ≑ x β€’ z" }, { "name": "IncludedN.trans", "content": "theorem IncludedN.trans : (x : Ξ±) β‰Ό{n} y β†’ y β‰Ό{n} z β†’ x β‰Ό{n} z" }, { "name": "incN_trans", "content": "theorem incN_trans {x y z : Ξ±} : x β‰Ό{n} y β†’ y β‰Ό{n} z β†’ x β‰Ό{n} z" }, { "name": "op_left_dist", "content": "theorem op_left_dist {x y : Ξ±} (z : Ξ±) (e : x ≑{n}≑ y) : x β€’ z ≑{n}≑ y β€’ z" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" }, { "name": "unit_right_id_dist", "content": "theorem unit_right_id_dist (x : Ξ±) : x β€’ unit ≑{n}≑ x" }, { "name": "unit_left_id_dist", "content": "theorem unit_left_id_dist {n} (x : Ξ±) : unit β€’ x ≑{n}≑ x" }, { "name": "Equiv.dist", "content": "theorem Equiv.dist [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ x ≑{n}≑ y" }, { "name": "valid_iff_validN'", "content": "theorem valid_iff_validN' [Discrete Ξ±] (n) {x : Ξ±} : βœ“ x ↔ βœ“{n} x" }, { "name": "validN_of_le", "content": "theorem validN_of_le {n n'} {x : Ξ±} : n' ≀ n β†’ βœ“{n} x β†’ βœ“{n'} x" }, { "name": "Valid.validN", "content": "theorem Valid.validN : βœ“ (x : Ξ±) β†’ βœ“{n} x" }, { "name": "IncludedN.validN", "content": "theorem IncludedN.validN {n} {x y : Ξ±} : x β‰Ό{n} y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "validN_of_incN", "content": "theorem validN_of_incN {n} {x y : Ξ±} : x β‰Ό{n} y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "_root_.Iris.OFE.Dist.validN", "content": "theorem _root_.Iris.OFE.Dist.validN : (x : Ξ±) ≑{n}≑ y β†’ (βœ“{n} x ↔ βœ“{n} y)" }, { "name": "validN_iff", "content": "theorem validN_iff {x y : Ξ±} (e : x ≑{n}≑ y) : βœ“{n} x ↔ βœ“{n} y" }, { "name": "Included.validN", "content": "theorem Included.validN {n} {x y : Ξ±} : x β‰Ό y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "validN_of_inc", "content": "theorem validN_of_inc {n} {x y : Ξ±} : x β‰Ό y β†’ βœ“{n} y β†’ βœ“{n} x" } ]
[ { "name": "Iris.LocalUpdate", "content": "def LocalUpdate [CMRA Ξ±] (x y : Ξ± Γ— Ξ±) : Prop :=\n βˆ€n mz, βœ“{n} x.1 β†’ x.1 ≑{n}≑ x.2 β€’? mz β†’ βœ“{n} y.1 ∧ y.1 ≑{n}≑ y.2 β€’? mz" } ]
[ { "name": "Iris.local_update_unital", "content": "theorem local_update_unital {x y x' y' : Ξ±} :\n (x, y) ~l~> (x', y') ↔ βˆ€ n z, βœ“{n} x β†’ x ≑{n}≑ y β€’ z β†’ (βœ“{n} x' ∧ x' ≑{n}≑ y' β€’ z)" } ]
import Iris.Algebra.CMRA namespace Iris def LocalUpdate [CMRA Ξ±] (x y : Ξ± Γ— Ξ±) : Prop := βˆ€n mz, βœ“{n} x.1 β†’ x.1 ≑{n}≑ x.2 β€’? mz β†’ βœ“{n} y.1 ∧ y.1 ≑{n}≑ y.2 β€’? mz infixr:50 " ~l~> " => LocalUpdate section localUpdate section CMRA variable [CMRA Ξ±] end CMRA section UCMRA variable [UCMRA Ξ±]
theorem local_update_unital_discrete [CMRA.Discrete Ξ±] (x y x' y' : Ξ±) : (x, y) ~l~> (x', y') ↔ βˆ€ z, βœ“ x β†’ x ≑ y β€’ z β†’ (βœ“ x' ∧ x' ≑ y' β€’ z) :=
where mp h z vx e := have ⟨vx', e'⟩ := h 0 (some z) (CMRA.Valid.validN vx) e.dist ⟨CMRA.discrete_valid vx', OFE.discrete_0 e'⟩ mpr h := by refine local_update_unital.mpr fun n z vnx e => ?_ have ⟨vx', e'⟩ := h z ((CMRA.valid_iff_validN' n).mpr vnx) (OFE.discrete e) exact ⟨vx'.validN, e'.dist⟩
5
51
false
Framework
238
Iris.BI.persistently_and_sep_assoc
theorem persistently_and_sep_assoc [BI PROP] {P Q R : PROP} : <pers> P ∧ (Q βˆ— R) ⊣⊒ (<pers> P ∧ Q) βˆ— R
iris-lean
src/Iris/BI/DerivedLaws.lean
[ "import Iris.BI.Extensions", "import Iris.Std.TC", "import Iris.Std.Classes", "import Iris.BI.BI", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import Iris.BI.Classes", "import Iris.Std.Rewrite" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term\n\nsyntax:max \"<affine> \" term:40 : term\n\nsyntax:max \"β–‘ \" term:40 : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" } ]
[]
[ { "name": "Iris.BI.and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "Iris.BI.and_mono_l", "content": "theorem and_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P ∧ Q ⊒ P' ∧ Q" }, { "name": "Iris.BI.sep_mono_l", "content": "theorem sep_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P βˆ— Q ⊒ P' βˆ— Q" }, { "name": "Iris.BI.sep_congr", "content": "@[rw_mono_rule]\ntheorem sep_congr [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊣⊒ Q) (h2 : P' ⊣⊒ Q') :\n (P βˆ— P') ⊣⊒ (Q βˆ— Q')" }, { "name": "Iris.BI.sep_congr_l", "content": "theorem sep_congr_l [BI PROP] {P P' Q : PROP} (h : P ⊣⊒ P') : P βˆ— Q ⊣⊒ P' βˆ— Q" }, { "name": "Iris.BI.sep_congr_r", "content": "theorem sep_congr_r [BI PROP] {P Q Q' : PROP} (h : Q ⊣⊒ Q') : P βˆ— Q ⊣⊒ P βˆ— Q'" }, { "name": "Iris.BI.sep_assoc", "content": "theorem sep_assoc [BI PROP] {P Q R : PROP} : (P βˆ— Q) βˆ— R ⊣⊒ P βˆ— Q βˆ— R" } ]
import Iris.BI.Classes import Iris.BI.Extensions import Iris.BI.BI import Iris.Std.Classes import Iris.Std.Rewrite import Iris.Std.TC namespace Iris.BI open Iris.Std BI
theorem persistently_and_sep_assoc [BI PROP] {P Q R : PROP} : <pers> P ∧ (Q βˆ— R) ⊣⊒ (<pers> P ∧ Q) βˆ— R :=
:= by constructor Β· refine (and_mono_l persistently_idem_2).trans <| persistently_and_affinely_sep.trans <| sep_assoc.2.trans <| sep_mono_l <| and_intro ?_ ?_ Β· exact (sep_mono_l and_elim_r).trans persistently_absorb_l Β· exact (sep_mono_l and_elim_l).trans emp_sep.1 Β· exact and_intro ((sep_mono_l and_elim_l).trans persistently_absorb_l) (sep_mono_l and_elim_r)
4
56
false
Framework
239
Iris.UpdateP.iso
theorem UpdateP.iso (gf : βˆ€ x, g (f x) ≑ x) (g_op : βˆ€ y1 y2, g (y1 β€’ y2) ≑ g y1 β€’ g y2) (g_validN : βˆ€ n y, βœ“{n} (g y) ↔ βœ“{n} y) (uyp : y ~~>: P) (pq : βˆ€ y', P y' β†’ Q (g y')) : g y ~~>: Q
iris-lean
src/Iris/Algebra/Updates.lean
[ "import Iris.Algebra.CMRA", "import src.Iris.Algebra.CMRA", "import src.Iris.Algebra.OFE" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Option.map", "module": "Init.Prelude" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x", "content": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "map", "content": "def map [OFE Ξ±] [OFE Ξ²] (f : Ξ± -n> Ξ²) (c : Chain Ξ±) : Chain Ξ² where\n chain n := f (c n)\n cauchy h := f.ne.1 (c.cauchy h)" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "Hom", "content": "@[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n f : Ξ± β†’ Ξ²\n ne : NonExpansive f" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -n> \" => Hom" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -C> \" => Hom" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "op_right_eqv", "content": "theorem op_right_eqv (x : Ξ±) {y z : Ξ±} (e : y ≑ z) : x β€’ y ≑ x β€’ z" }, { "name": "Equiv.rfl", "content": "@[simp, refl] theorem Equiv.rfl [OFE Ξ±] {x : Ξ±} : x ≑ x" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" } ]
[ { "name": "Iris.UpdateP", "content": "def UpdateP [CMRA Ξ±] (x : Ξ±) (P : Ξ± β†’ Prop) := βˆ€ n mz,\n βœ“{n} (x β€’? mz) β†’ βˆƒ y, P y ∧ βœ“{n} (y β€’? mz)" }, { "name": "Iris.Update", "content": "def Update [CMRA Ξ±] (x y : Ξ±) := βˆ€ n mz,\n βœ“{n} (x β€’? mz) β†’ βœ“{n} (y β€’? mz)" } ]
[]
import Iris.Algebra.CMRA namespace Iris def UpdateP [CMRA Ξ±] (x : Ξ±) (P : Ξ± β†’ Prop) := βˆ€ n mz, βœ“{n} (x β€’? mz) β†’ βˆƒ y, P y ∧ βœ“{n} (y β€’? mz) infixr:50 " ~~>: " => UpdateP def Update [CMRA Ξ±] (x y : Ξ±) := βˆ€ n mz, βœ“{n} (x β€’? mz) β†’ βœ“{n} (y β€’? mz) infixr:50 " ~~> " => Update section updates variable [CMRA Ξ±] [CMRA Ξ²] (f : Ξ± β†’ Ξ²) (g : Ξ² β†’ Ξ±)
theorem UpdateP.iso (gf : βˆ€ x, g (f x) ≑ x) (g_op : βˆ€ y1 y2, g (y1 β€’ y2) ≑ g y1 β€’ g y2) (g_validN : βˆ€ n y, βœ“{n} (g y) ↔ βœ“{n} y) (uyp : y ~~>: P) (pq : βˆ€ y', P y' β†’ Q (g y')) : g y ~~>: Q :=
:= by intro n mz v have : βœ“{n} y β€’? Option.map f mz := match mz with | none => (g_validN n _).mp v | some z => have : g y β€’ z ≑ g (y β€’ f z) := (CMRA.op_right_eqv _ (gf z).symm).trans (g_op y (f z)).symm (g_validN n _).mp (CMRA.validN_ne this.dist v) have ⟨x, px, vx⟩ := uyp n (mz.map f) this have : g (x β€’? Option.map f mz) ≑ g x β€’? mz := match mz with | none => OFE.Equiv.rfl | some z => (g_op x (f z)).trans (CMRA.op_right_eqv (g x) (gf z)) exact ⟨g x, pq x px, CMRA.validN_ne this.dist ((g_validN n _).mpr vx)⟩
4
31
false
Framework
240
Iris.OFE.equiv_eqv
theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv
iris-lean
src/Iris/Algebra/OFE.lean
[ "import src/Iris/Algebra/CMRA.lean", "import src/Iris/Instances/UPred/Instance.lean", "import src/Iris/Algebra/Agree_task.lean", "import src/Iris/Algebra/COFESolver.lean", "import src/Iris/Algebra/Heap.lean" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Dist", "module": "Mathlib.Topology.MetricSpace.Pseudo.Defs" }, { "name": "Equiv", "module": "Mathlib.Logic.Equiv.Defs" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Nat.succ", "module": "Init.Prelude" }, { "name": "k", "module": "QqTest.matching" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "", "content": "instance : OFE.Discrete (DFrac F) := ⟨congrArg id⟩" }, { "name": "Agree.dist", "content": "def Agree.dist (n : Nat) (x y : Agree Ξ±) : Prop :=\n (βˆ€ a ∈ x.car, βˆƒ b ∈ y.car, a ≑{n}≑ b) ∧\n (βˆ€ b ∈ y.car, βˆƒ a ∈ x.car, a ≑{n}≑ b)" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "", "content": "instance : OFE (Tower F) where\n Equiv f g := βˆ€ k, f k ≑ g k\n Dist n f g := βˆ€ k, f k ≑{n}≑ g k\n dist_eqv := {\n refl _ _ := dist_eqv.refl _\n symm h _ := dist_eqv.symm (h _)\n trans h1 h2 _ := dist_eqv.trans (h1 _) (h2 _)\n }\n equiv_dist {_ _} := by admit /- proof elided -/" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "", "content": "instance : OFE.NonExpansive (BUpd.bupd (PROP := UPred M)) := bupd_ne" }, { "name": "bupd_ne", "content": "instance bupd_ne : OFE.NonExpansive (bupd : UPred M β†’ UPred M) where\n ne n x1 x2 Hx m y Hm Hv := by admit /- proof elided -/" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "later_contractive", "content": "instance later_contractive : OFE.Contractive UPred.later (Ξ± := UPred M) where\n distLater_dist {n x y} Hl :=\n match n with\n | 0 => by admit /- proof elided -/\n | n + 1 => fun\n | 0 => by admit /- proof elided -/\n | n' + 1 => fun x' Hn' Hx' => Hl _ Hn' _ _ (Nat.le_refl _) (CMRA.validN_succ Hx')" }, { "name": "later", "content": "protected def later (P : UPred M) : UPred M where\n holds n x := match n with | 0 => True | Nat.succ n' => P n' x\n mono {n₁ nβ‚‚} := by admit /- proof elided -/" }, { "name": "BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "BIUpdate", "content": "class BIUpdate (PROP : Type _) [BI PROP] extends BUpd PROP where\n [bupd_ne : OFE.NonExpansive (BUpd.bupd (PROP := PROP))]\n intro {P : PROP} : iprop(P ⊒ |==> P)\n mono {P Q : PROP} : iprop(P ⊒ Q) β†’ iprop(|==> P ⊒ |==> Q)\n trans {P : PROP} : iprop(|==> |==> P ⊒ |==> P)\n frame_r {P R : PROP} : iprop((|==> P) βˆ— R ⊒ |==> (P βˆ— R))" }, { "name": "UPred", "content": "@[ext]\nstructure UPred (M : Type _) [UCMRA M] where\n holds : Nat β†’ M β†’ Prop\n mono {n1 n2 x1 x2} : holds n1 x1 β†’ x1 β‰Ό{n2} x2 β†’ n2 ≀ n1 β†’ holds n2 x2" }, { "name": "IsModal", "content": "class IsModal [BI PROP1] [BI PROP2] (M : PROP1 β†’ PROP2)\n (iaction saction : ModalityAction PROP1 PROP2) where\n spec_intuitionistic : iaction.intuitionistic_action_spec M\n spec_spatial : saction.spatial_action_spec M\n emp : iprop(emp) ⊒ M iprop(emp)\n mono : βˆ€ {P Q}, (P ⊒ Q) β†’ M P ⊒ M Q\n sep : βˆ€ {P Q}, iprop(M P βˆ— M Q) ⊒ M iprop(P βˆ— Q)" }, { "name": "UCMRA", "content": "class UCMRA (Ξ± : Type _) extends CMRA Ξ± where\n unit : Ξ±\n unit_valid : βœ“ unit\n unit_left_id : unit β€’ x ≑ x\n pcore_unit : pcore unit ≑ some unit" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "instOFE", "content": "instance instOFE [Store T K V] [OFE V] : OFE T where\n Equiv s0 s1 := get s0 ≑ get s1\n Dist n s0 s1 := get s0 ≑{n}≑ get s1\n dist_eqv := ⟨fun _ => .of_eq rfl, (Β·.symm), (Β·.trans Β·)⟩\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "Store.Equiv", "content": "@[simp] def Store.Equiv [Store T K V] (t1 t2 : T) : Prop := get t1 = get t2" }, { "name": "Store.Equiv_trans", "content": "instance Store.Equiv_trans [Store T K V] : Trans Equiv (Equiv (T := T)) Equiv := ⟨by admit /- proof elided -/\n⟩" }, { "name": "[CMRA", "content": "instance [CMRA Ξ²] : OFE (Ξ± -C> Ξ²) where\n Equiv f g := f.toHom ≑ g.toHom\n Dist n f g := f.toHom ≑{n}≑ g.toHom\n dist_eqv := {\n refl _ := dist_eqv.refl _\n symm h := dist_eqv.symm h\n trans h1 h2 := dist_eqv.trans h1 h2\n }\n equiv_dist := equiv_dist\n dist_lt := dist_lt" }, { "name": "[Store", "content": "instance [Store T1 K V1] [Store T2 K V2] [OFE V1] [OFE V2] (f : K β†’ V1 β†’ V2)\n [βˆ€ k, NonExpansive (f k)] [HasStoreMap T1 T2 K V1 V2] : NonExpansive (dmap f : T1 β†’ T2) where\n ne _ {_ _} H k := by admit /- proof elided -/" }, { "name": "[Heap", "content": "instance [Heap T K V] [OFE V] (op : V β†’ V β†’ V) [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (merge (T := T) op) where\n ne _ {_ _} Ht {_ _} Hs k := by admit /- proof elided -/" }, { "name": "Heap.instCOFE", "content": "instance Heap.instCOFE [Heap T K V] [COFE V] : COFE T where\n compl c := hmap (fun _ => COFE.compl <| c.map ⟨_, Store.get_ne ·⟩) (c 0)\n conv_compl {_ c} k := by admit /- proof elided -/" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Iris.OFE", "content": "class OFE (Ξ± : Type _) where\n Equiv : Ξ± β†’ Ξ± β†’ Prop\n Dist : Nat β†’ Ξ± β†’ Ξ± β†’ Prop\n dist_eqv : Equivalence (Dist n)\n equiv_dist : Equiv x y ↔ βˆ€ n, Dist n x y\n dist_lt : Dist n x y β†’ m < n β†’ Dist m x y" } ]
[ { "name": "Iris.OFE.Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "Iris.OFE.Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Iris.OFE.Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" } ]
namespace Iris class OFE (Ξ± : Type _) where Equiv : Ξ± β†’ Ξ± β†’ Prop Dist : Nat β†’ Ξ± β†’ Ξ± β†’ Prop dist_eqv : Equivalence (Dist n) equiv_dist : Equiv x y ↔ βˆ€ n, Dist n x y dist_lt : Dist n x y β†’ m < n β†’ Dist m x y open OFE scoped infix:40 " ≑ " => OFE.Equiv scoped notation:40 x " ≑{" n "}≑ " y:41 => OFE.Dist n x y namespace OFE
theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv :=
:= by constructor Β· rintro x; rw [ofe.equiv_dist]; rintro n; exact Dist.rfl Β· rintro x y; simp [ofe.equiv_dist]; rintro h n; exact Dist.symm (h n) Β· rintro x y z; simp [ofe.equiv_dist]; rintro h₁ hβ‚‚ n; exact Dist.trans (h₁ n) (hβ‚‚ n)
3
14
false
Framework
241
Iris.BI.plainly_sep
theorem plainly_sep [BIPositive PROP] : β–  (P βˆ— Q) ⊣⊒ β–  P βˆ— β–  Q
iris-lean
src/Iris/BI/Plainly.lean
[ "import Iris.Algebra", "import src.Iris.BI.DerivedLaws", "import src/Iris/Instances/UPred/Instance.lean", "import Iris.BI.DerivedLaws", "import Iris.BI.BI", "import src.Iris.BI.BI", "import Iris.BI.Classes" ]
[ { "name": "Lean.MonadQuotation", "module": "Init.Prelude" }, { "name": "Lean.MonadRef", "module": "Init.Prelude" }, { "name": "Monad", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "syntax term:26 \" ==βˆ— \" term:25 : term", "content": "syntax term:26 \" ==βˆ— \" term:25 : term\n\nsyntax term \"={ \" term \" , \" term \" }=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }[ \" term \" ]β–·=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }β–·=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }[ \" term \" ]β–·^\" term \"=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }β–·^\" term \"=βˆ— \" term : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term" }, { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term\n\nsyntax \"β–  \" term:40 : term\n\nsyntax:max \"<affine> \" term:40 : term" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|==> $P)) => ``(BUpd.bupd iprop($P))\n | `(iprop($P ==βˆ— $Q)) => ``(BIBase.wand iprop($P) (BUpd.bupd iprop($Q)))\n\ndelab_rule BUpd.bupd\n | `($_ $P) => do ``(iprop(|==> $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 , $E2 }=> $P)) => ``(FUpd.fupd $E1 $E2 iprop($P))\n | `(iprop($P ={ $E1 , $E2 }=βˆ— $Q)) => ``(BIBase.wand iprop($P) (FUpd.fupd $E1 $E2 iprop($Q)))\n | `(iprop(|={ $E1 }=> $P)) => ``(FUpd.fupd $E1 $E1 iprop($P))\n | `(iprop($P ={ $E1 }=βˆ— $Q)) => ``(BIBase.wand iprop($P) (FUpd.fupd $E1 $E1 iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 }[ $E2 ]β–·=> $P)) => ``(iprop(|={$E1, $E2}=> β–· (|={ $E2, $E1 }=> iprop($P))))\n | `(iprop($P ={ $E1 }[ $E2 ]β–·=βˆ— $Q)) => ``(iprop(iprop($P) -βˆ— |={$E1}[$E2]β–·=> iprop($Q)))\n | `(iprop(|={ $E1 }β–·=> $P)) => ``(iprop(|={$E1}[$E1]β–·=> iprop($P)))\n | `(iprop($P ={ $E1 }β–·=βˆ— $Q)) => ``(iprop(iprop($P) ={$E1}[$E1]β–·=βˆ— iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 }[ $E2 ]β–·^$n=> $P)) => ``(iprop(|={$E1, $E2}=> β–·^[$n] (|={ $E2, $E1 }=> iprop($P))))\n | `(iprop($P ={ $E1 }[ $E2 ]β–·^$n=βˆ— $Q)) => ``(iprop(iprop($P) -βˆ— |={$E1}[$E2]β–·^$n=> iprop($Q)))\n | `(iprop(|={ $E1 }β–·^$n=> $P)) => ``(iprop(|={$E1}[$E1]β–·^$n=> iprop($P)))\n | `(iprop($P ={ $E1 }β–·^$n=βˆ— $Q)) => ``(iprop(iprop($P) ={$E1}[$E1]β–·^$n=βˆ— iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–  $P)) => ``(Plainly.plainly iprop($P))\n\ndelab_rule Plainly.plainly\n | `($_ $P) => do ``(iprop(β–  $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β– ? $p $P)) => ``(Plainly.plainlyIf $p iprop($P))\n\ndelab_rule Plainly.plainlyIf\n | `($_ $p $P) => do ``(iprop(β– ? $p $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "unpackIprop", "content": "partial def unpackIprop [Monad m] [MonadRef m] [MonadQuotation m] : Term β†’ m Term\n | `(iprop($P)) => do `($P)\n | `($P:ident) => do `($P)\n | `(?$P:ident) => do `(?$P)\n | `(($P)) => do `(($(← unpackIprop P)))\n | `($P $[ $Q]*) => do ``($P $[ $Q]*)\n | `(if $c then $t else $e) => do\n let t ← unpackIprop t\n let e ← unpackIprop e\n `(if $c then $t else $e)\n | `(($P : $t)) => do ``(($(← unpackIprop P) : $t))\n | `($t) => `($t:term)" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "BIPositive", "content": "class BIPositive (PROP : Type _) [BI PROP] where\n affinely_sep_l {P Q : PROP} : <affine> (P βˆ— Q) ⊒ <affine> P βˆ— Q" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "Idempotent", "content": "class Idempotent (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n idem {x : Ξ±} : R (f x x) x" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "", "content": "instance : BIPlainly (UPred M) where\n mono H _ _ _ := H _ _ CMRA.unit_validN\n elim_persistently {P} n x Hx := by admit /- proof elided -/" }, { "name": "persistently", "content": "protected def persistently (P : UPred M) : UPred M where\n holds n x := P n (CMRA.core x)\n mono H Hx Hn := P.mono H (CMRA.core_incN_core Hx) Hn" }, { "name": "BIUpdate", "content": "class BIUpdate (PROP : Type _) [BI PROP] extends BUpd PROP where\n [bupd_ne : OFE.NonExpansive (BUpd.bupd (PROP := PROP))]\n intro {P : PROP} : iprop(P ⊒ |==> P)\n mono {P Q : PROP} : iprop(P ⊒ Q) β†’ iprop(|==> P ⊒ |==> Q)\n trans {P : PROP} : iprop(|==> |==> P ⊒ |==> P)\n frame_r {P R : PROP} : iprop((|==> P) βˆ— R ⊒ |==> (P βˆ— R))" }, { "name": "UPred", "content": "@[ext]\nstructure UPred (M : Type _) [UCMRA M] where\n holds : Nat β†’ M β†’ Prop\n mono {n1 n2 x1 x2} : holds n1 x1 β†’ x1 β‰Ό{n2} x2 β†’ n2 ≀ n1 β†’ holds n2 x2" }, { "name": "IsModal", "content": "class IsModal [BI PROP1] [BI PROP2] (M : PROP1 β†’ PROP2)\n (iaction saction : ModalityAction PROP1 PROP2) where\n spec_intuitionistic : iaction.intuitionistic_action_spec M\n spec_spatial : saction.spatial_action_spec M\n emp : iprop(emp) ⊒ M iprop(emp)\n mono : βˆ€ {P Q}, (P ⊒ Q) β†’ M P ⊒ M Q\n sep : βˆ€ {P Q}, iprop(M P βˆ— M Q) ⊒ M iprop(P βˆ— Q)" }, { "name": "core", "content": "def core (x : Ξ±) := (pcore x).getD x" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "UCMRA", "content": "class UCMRA (Ξ± : Type _) extends CMRA Ξ± where\n unit : Ξ±\n unit_valid : βœ“ unit\n unit_left_id : unit β€’ x ≑ x\n pcore_unit : pcore unit ≑ some unit" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "plainly", "content": "protected def plainly (P : UPred M) : UPred M where\n holds n _ := P n UCMRA.unit\n mono H _ Hn := P.mono H (CMRA.incN_refl UCMRA.unit) Hn" }, { "name": "BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "", "content": "instance : BIPlainlyExists (UPred M) where\n plainly_sExists_1 _ _ _ := fun ⟨_, hp⟩ => ⟨_, ⟨_, rfl⟩, hp⟩" }, { "name": "BIPlainlyExists", "content": "class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where\n plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p" }, { "name": "", "content": "instance : Plainly (UPred M) := ⟨UPred.plainly⟩" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "persistently_and_sep_assoc", "content": "theorem persistently_and_sep_assoc [BI PROP] {P Q R : PROP} :\n <pers> P ∧ (Q βˆ— R) ⊣⊒ (<pers> P ∧ Q) βˆ— R" }, { "name": "and_mono_l", "content": "theorem and_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P ∧ Q ⊒ P' ∧ Q" }, { "name": "and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" }, { "name": "and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "sep_assoc", "content": "theorem sep_assoc [BI PROP] {P Q R : PROP} : (P βˆ— Q) βˆ— R ⊣⊒ P βˆ— Q βˆ— R" }, { "name": "sep_congr_l", "content": "theorem sep_congr_l [BI PROP] {P P' Q : PROP} (h : P ⊣⊒ P') : P βˆ— Q ⊣⊒ P' βˆ— Q" }, { "name": "sep_congr", "content": "@[rw_mono_rule]\ntheorem sep_congr [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊣⊒ Q) (h2 : P' ⊣⊒ Q') :\n (P βˆ— P') ⊣⊒ (Q βˆ— Q')" }, { "name": "sep_congr_r", "content": "theorem sep_congr_r [BI PROP] {P Q Q' : PROP} (h : Q ⊣⊒ Q') : P βˆ— Q ⊣⊒ P βˆ— Q'" }, { "name": "sep_mono_l", "content": "theorem sep_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P βˆ— Q ⊒ P' βˆ— Q" }, { "name": "BIBase.Entails.rfl", "content": "@[simp] theorem BIBase.Entails.rfl [BI PROP] {P : PROP} : P ⊒ P" }, { "name": "imp_intro'", "content": "theorem imp_intro' [BI PROP] {P Q R : PROP} (h : Q ∧ P ⊒ R) : P ⊒ Q β†’ R" }, { "name": "and_comm", "content": "theorem and_comm [BI PROP] {P Q : PROP} : P ∧ Q ⊣⊒ Q ∧ P" }, { "name": "and_symm", "content": "theorem and_symm [BI PROP] {P Q : PROP} : P ∧ Q ⊒ Q ∧ P" }, { "name": "imp_elim'", "content": "theorem imp_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P β†’ R) : P ∧ Q ⊒ R" }, { "name": "pure_elim", "content": "theorem pure_elim [BI PROP] (Ο† : Prop) {Q R : PROP} (h1 : Q ⊒ βŒœΟ†βŒ) (h2 : Ο† β†’ Q ⊒ R) : Q ⊒ R" }, { "name": "and_self", "content": "theorem and_self [BI PROP] {P : PROP} : P ∧ P ⊣⊒ P" }, { "name": "forall_intro", "content": "theorem forall_intro [BI PROP] {P : PROP} {Ξ¨ : Ξ± β†’ PROP} (h : βˆ€ a, P ⊒ Ξ¨ a) : P ⊒ βˆ€ a, Ξ¨ a" }, { "name": "forall_elim", "content": "theorem forall_elim [BI PROP] {Ξ¨ : Ξ± β†’ PROP} (a : Ξ±) : (βˆ€ a, Ξ¨ a) ⊒ Ξ¨ a" }, { "name": "forall_mono", "content": "@[rw_mono_rule]\ntheorem forall_mono [BI PROP] {Ξ¦ Ξ¨ : Ξ± β†’ PROP} (h : βˆ€ a, Ξ¦ a ⊒ Ξ¨ a) : (βˆ€ a, Ξ¦ a) ⊒ βˆ€ a, Ξ¨ a" }, { "name": "and_forall_bool", "content": "theorem and_forall_bool [BI PROP] {P Q : PROP} :\n P ∧ Q ⊣⊒ Β«forallΒ» (fun b : Bool => if b then P else Q)" }, { "name": "persistently_and_emp_elim", "content": "theorem persistently_and_emp_elim {P : PROP} [BI PROP] : emp ∧ <pers> P ⊒ P" }, { "name": "sep_emp", "content": "theorem sep_emp [BI PROP] {P : PROP} : P βˆ— emp ⊣⊒ P" }, { "name": "affinely_elim_emp", "content": "theorem affinely_elim_emp [BI PROP] {P : PROP} : <affine> P ⊒ emp" }, { "name": "affinely_sep", "content": "theorem affinely_sep [BI PROP] [BIPositive PROP] {P Q : PROP} :\n <affine> (P βˆ— Q) ⊣⊒ <affine> P βˆ— <affine> Q" }, { "name": "affinely_idem", "content": "theorem affinely_idem [BI PROP] {P : PROP} : <affine> <affine> P ⊣⊒ <affine> P" }, { "name": "and_assoc", "content": "theorem and_assoc [BI PROP] {P Q R : PROP} : (P ∧ Q) ∧ R ⊣⊒ P ∧ Q ∧ R" }, { "name": "and_mono_r", "content": "theorem and_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P ∧ Q ⊒ P ∧ Q'" }, { "name": "and_congr_l", "content": "theorem and_congr_l [BI PROP] {P P' Q : PROP} (h : P ⊣⊒ P') : P ∧ Q ⊣⊒ P' ∧ Q" }, { "name": "and_congr", "content": "@[rw_mono_rule]\ntheorem and_congr [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊣⊒ Q) (h2 : P' ⊣⊒ Q') : P ∧ P' ⊣⊒ Q ∧ Q'" }, { "name": "affinely_mono", "content": "@[rw_mono_rule]\ntheorem affinely_mono [BI PROP] {P Q : PROP} : (P ⊒ Q) β†’ <affine> P ⊒ <affine> Q" }, { "name": "affinely_sep_2", "content": "theorem affinely_sep_2 [BI PROP] {P Q : PROP} : <affine> P βˆ— <affine> Q ⊒ <affine> (P βˆ— Q)" }, { "name": "affinely_elim", "content": "theorem affinely_elim [BI PROP] {P : PROP} : <affine> P ⊒ P" }, { "name": "affinely_sep_r", "content": "theorem affinely_sep_r [BI PROP] [BIPositive PROP] {P Q : PROP} :\n <affine> (P βˆ— Q) ⊒ P βˆ— <affine> Q" } ]
[ { "name": "Iris.Plainly", "content": "class Plainly (PROP : Type _) where\n plainly : PROP β†’ PROP" }, { "name": "Iris.Plainly.plainlyIf", "content": "def Plainly.plainlyIf [Iris.BI.BIBase PROP] [Plainly PROP] (p : Bool) (P : PROP) : PROP :=\n iprop(if p then β–  P else P)" }, { "name": "Iris.BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "Iris.BIPlainlyExists", "content": "class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where\n plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p" } ]
[ { "name": "Iris.BI.persistently_elim_plainly", "content": "theorem persistently_elim_plainly : <pers> β–  P ⊣⊒ β–  P" }, { "name": "Iris.BI.plainly_forall_2", "content": "theorem plainly_forall_2 {Ξ¨ : Ξ± β†’ PROP} : (βˆ€ a, β–  (Ξ¨ a)) ⊒ β–  (βˆ€ a, Ξ¨ a)" }, { "name": "Iris.BI.plainly_and_sep_assoc", "content": "theorem plainly_and_sep_assoc : β–  P ∧ (Q βˆ— R) ⊣⊒ (β–  P ∧ Q) βˆ— R" }, { "name": "Iris.BI.plainly_and_emp_elim", "content": "theorem plainly_and_emp_elim : emp ∧ β–  P ⊒ P" }, { "name": "Iris.BI.plainly_forall", "content": "theorem plainly_forall {Ξ¨ : Ξ± β†’ PROP} : β–  (βˆ€ a, Ξ¨ a) ⊣⊒ βˆ€ a, β–  (Ξ¨ a)" }, { "name": "Iris.BI.plainly_and", "content": "theorem plainly_and : β–  (P ∧ Q) ⊣⊒ β–  P ∧ β–  Q" }, { "name": "Iris.BI.plainly_and_sep_l_1", "content": "theorem plainly_and_sep_l_1 : β–  P ∧ Q ⊒ β–  P βˆ— Q" }, { "name": "Iris.BI.plainly_and_sep", "content": "theorem plainly_and_sep : β–  (P ∧ Q) ⊒ β–  (P βˆ— Q)" }, { "name": "Iris.BI.and_sep_plainly", "content": "theorem and_sep_plainly : β–  P ∧ β–  Q ⊣⊒ β–  P βˆ— β–  Q" }, { "name": "Iris.BI.plainly_sep_2", "content": "theorem plainly_sep_2 : β–  P βˆ— β–  Q ⊒ β–  (P βˆ— Q)" } ]
import Iris.BI.Classes import Iris.BI.BI import Iris.BI.DerivedLaws import Iris.Algebra namespace Iris open BI class Plainly (PROP : Type _) where plainly : PROP β†’ PROP def Plainly.plainlyIf [Iris.BI.BIBase PROP] [Plainly PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–  P else P) class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))] mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q elim_persistently {P : PROP} : β–  P ⊒ <pers> P idem {P : PROP} : β–  P ⊒ β–  β–  P plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦ plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q) emp_intro {P : PROP} : P ⊒ β–  emp plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p namespace BI open Iris.Std section PlainlyLaws open BIPlainly variable [BI PROP] [BIPlainly PROP] variable {P Q R : PROP}
theorem plainly_sep [BIPositive PROP] : β–  (P βˆ— Q) ⊣⊒ β–  P βˆ— β–  Q :=
:= by refine ⟨?_, plainly_sep_2⟩ refine plainly_affinely_elim.mpr.trans ?_ refine (mono <| affinely_sep.mp).trans ?_ refine .trans ?_ and_sep_plainly.mp refine and_intro (mono ?_) (mono ?_) · exact ((sep_mono .rfl affinely_elim_emp).trans sep_emp.mp).trans affinely_elim · exact ((sep_mono affinely_elim_emp .rfl).trans emp_sep.mp).trans affinely_elim
7
72
false
Framework
242
Iris.Agree.toAgree_uninj
theorem Agree.toAgree_uninj {x : Agree Ξ±} : βœ“ x β†’ βˆƒ a, toAgree a ≑ x
iris-lean
src/Iris/Algebra/Agree.lean
[ "import Iris.Algebra.CMRA", "import src.Iris.Algebra.CMRA", "import src.Iris.Algebra.OFE", "import Iris.Algebra.OFE" ]
[ { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "m", "module": "QqTest.matching" } ]
[ { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x", "content": "notation:50 \"βœ“{\" n \"} \" x:51 => ValidN n x" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "valid", "content": "def valid : DFrac F β†’ Prop\n | .own f => Proper f\n | .discard => True\n | .ownDiscard f => Fractional f" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "Fractional", "content": "def Fractional [Fraction Ξ±] (a : Ξ±) : Prop := βˆƒ b, Proper (a + b)" }, { "name": "Fraction", "content": "class Fraction (Ξ± : Type _) extends Add Ξ± where\n \n Proper : Ξ± β†’ Prop\n add_comm : βˆ€ a b : Ξ±, a + b = b + a\n add_assoc : βˆ€ a b c : Ξ±, a + (b + c) = (a + b) + c\n add_left_cancel : βˆ€ {a b c : Ξ±}, a + b = a + c β†’ b = c\n \n add_ne : βˆ€ {a b : Ξ±}, a β‰  b + a\n proper_add_mono_left : βˆ€ {a b : Ξ±}, Proper (a + b) β†’ Proper a" }, { "name": "Agree", "content": "@[ext]\nstructure Agree where\n car : List Ξ±\n not_nil : car β‰  []" }, { "name": "LeibnizO", "content": "@[ext] structure LeibnizO (Ξ± : Type _) where\n car : Ξ±" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "Iso.symm", "content": "def Iso.symm [OFE Ξ±] [OFE Ξ²] (iso : Iso Ξ± Ξ²) : Iso Ξ² Ξ± where\n hom := iso.inv\n inv := iso.hom\n hom_inv := by admit /- proof elided -/" }, { "name": "Iso", "content": "@[ext] structure Iso (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n hom : Ξ± -n> Ξ²\n inv : Ξ² -n> Ξ±\n hom_inv : hom (inv x) ≑ x\n inv_hom : inv (hom x) ≑ x" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "Hom", "content": "@[ext] structure Hom (Ξ± Ξ² : Type _) [CMRA Ξ±] [CMRA Ξ²] extends OFE.Hom Ξ± Ξ² where\n protected validN {n x} : βœ“{n} x β†’ βœ“{n} (f x)\n protected pcore x : (pcore x).map f ≑ pcore (f x)\n protected op x y : f (x β€’ y) ≑ f x β€’ f y" }, { "name": "Hom", "content": "@[ext] structure Hom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] where\n f : Ξ± β†’ Ξ²\n ne : NonExpansive f" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -n> \" => Hom" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" }, { "name": "@[inherit_doc]", "content": "@[inherit_doc]\ninfixr:25 \" -C> \" => Hom" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "_root_.Iris.OFE.Dist.validN", "content": "theorem _root_.Iris.OFE.Dist.validN : (x : Ξ±) ≑{n}≑ y β†’ (βœ“{n} x ↔ βœ“{n} y)" }, { "name": "validN_iff", "content": "theorem validN_iff {x y : Ξ±} (e : x ≑{n}≑ y) : βœ“{n} x ↔ βœ“{n} y" }, { "name": "IncludedN.validN", "content": "theorem IncludedN.validN {n} {x y : Ξ±} : x β‰Ό{n} y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "validN_of_incN", "content": "theorem validN_of_incN {n} {x y : Ξ±} : x β‰Ό{n} y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "Included.validN", "content": "theorem Included.validN {n} {x y : Ξ±} : x β‰Ό y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "validN_of_inc", "content": "theorem validN_of_inc {n} {x y : Ξ±} : x β‰Ό y β†’ βœ“{n} y β†’ βœ“{n} x" }, { "name": "Valid.validN", "content": "theorem Valid.validN : βœ“ (x : Ξ±) β†’ βœ“{n} x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "_root_.Iris.OFE.Equiv.valid", "content": "theorem _root_.Iris.OFE.Equiv.valid : (x : Ξ±) ≑ y β†’ (βœ“ x ↔ βœ“ y)" }, { "name": "valid_iff", "content": "theorem valid_iff {x y : Ξ±} (e : x ≑ y) : βœ“ x ↔ βœ“ y" }, { "name": "valid_of_eqv", "content": "theorem valid_of_eqv {x y : Ξ±} : x ≑ y β†’ βœ“ x β†’ βœ“ y" }, { "name": "valid_mapN", "content": "theorem valid_mapN {x y : Ξ±} (f : βˆ€ n, βœ“{n} x β†’ βœ“{n} y) (v : βœ“ x) : βœ“ y" }, { "name": "validN_of_eqv", "content": "theorem validN_of_eqv {x y : Ξ±} : x ≑ y β†’ βœ“{n} x β†’ βœ“{n} y" }, { "name": "Hom.valid", "content": "protected theorem Hom.valid [CMRA Ξ²] (f : Ξ± -C> Ξ²) {x : Ξ±} (H : βœ“ x) : βœ“ f x" } ]
[ { "name": "Iris.Agree", "content": "@[ext]\nstructure Agree where\n car : List Ξ±\n not_nil : car β‰  []" }, { "name": "Iris.toAgree", "content": "def toAgree (a : Ξ±) : Agree Ξ± := ⟨[a], by admit /- proof elided -/\n⟩" }, { "name": "Iris.Agree.dist", "content": "def Agree.dist (n : Nat) (x y : Agree Ξ±) : Prop :=\n (βˆ€ a ∈ x.car, βˆƒ b ∈ y.car, a ≑{n}≑ b) ∧\n (βˆ€ b ∈ y.car, βˆƒ a ∈ x.car, a ≑{n}≑ b)" }, { "name": "Iris.Agree.validN", "content": "def Agree.validN (n : Nat) (x : Agree Ξ±) : Prop :=\n match x.car with\n | [_] => True\n | _ => βˆ€ a ∈ x.car, βˆ€ b ∈ x.car, a ≑{n}≑ b" }, { "name": "Iris.Agree.valid", "content": "def Agree.valid (x : Agree Ξ±) : Prop := βˆ€ n, x.validN n" } ]
[ { "name": "Iris.mem_of_agree", "content": "theorem mem_of_agree (x : Agree Ξ±) : βˆƒ a, a ∈ x.car" }, { "name": "Iris.Agree.equiv_def", "content": "theorem Agree.equiv_def {x y : Agree Ξ±} : x ≑ y ↔ βˆ€ n, Agree.dist n x y" }, { "name": "Iris.Agree.validN_iff", "content": "theorem Agree.validN_iff {x : Agree Ξ±} :\n x.validN n ↔ βˆ€ a ∈ x.car, βˆ€ b ∈ x.car, a ≑{n}≑ b" }, { "name": "Iris.Agree.valid_def", "content": "theorem Agree.valid_def {x : Agree Ξ±} : βœ“ x ↔ x.valid" } ]
import Iris.Algebra.CMRA import Iris.Algebra.OFE namespace Iris section agree variable {Ξ± : Type u} variable (Ξ±) in @[ext] structure Agree where car : List Ξ± not_nil : car β‰  [] def toAgree (a : Ξ±) : Agree Ξ± := ⟨[a], by admit /- proof elided -/ ⟩ variable [OFE Ξ±] def Agree.dist (n : Nat) (x y : Agree Ξ±) : Prop := (βˆ€ a ∈ x.car, βˆƒ b ∈ y.car, a ≑{n}≑ b) ∧ (βˆ€ b ∈ y.car, βˆƒ a ∈ x.car, a ≑{n}≑ b) def Agree.validN (n : Nat) (x : Agree Ξ±) : Prop := match x.car with | [_] => True | _ => βˆ€ a ∈ x.car, βˆ€ b ∈ x.car, a ≑{n}≑ b def Agree.valid (x : Agree Ξ±) : Prop := βˆ€ n, x.validN n
theorem Agree.toAgree_uninj {x : Agree Ξ±} : βœ“ x β†’ βˆƒ a, toAgree a ≑ x :=
:= by simp only [valid_def, valid, validN_iff, equiv_def] obtain ⟨a, ha⟩ := mem_of_agree x intro h; exists a; intro n constructor <;> intros · exists a; simp_all [toAgree] · simp_all [toAgree]
7
53
false
Framework
243
Iris.BI.plainly_sep_dup
theorem plainly_sep_dup : β–  P ⊣⊒ β–  P βˆ— β–  P
iris-lean
src/Iris/BI/Plainly.lean
[ "import Iris.Algebra", "import Iris.BI.DerivedLaws", "import src.Iris.Algebra.CMRA", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import src.Iris.BI.DerivedLaws", "import src/Iris/Instances/UPred/Instance.lean", "import Iris.BI.BI", "import Iris.BI.Classes" ]
[ { "name": "Lean.MonadQuotation", "module": "Init.Prelude" }, { "name": "Lean.MonadRef", "module": "Init.Prelude" }, { "name": "Monad", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" } ]
[ { "name": "syntax term:26 \" ==βˆ— \" term:25 : term", "content": "syntax term:26 \" ==βˆ— \" term:25 : term\n\nsyntax term \"={ \" term \" , \" term \" }=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }[ \" term \" ]β–·=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }β–·=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }[ \" term \" ]β–·^\" term \"=βˆ— \" term : term\n\nsyntax term \"={ \" term \" }β–·^\" term \"=βˆ— \" term : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term" }, { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term\n\nsyntax \"β–  \" term:40 : term" }, { "name": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y", "content": "notation:50 x \" β‰Ό{\" n \"} \" y:51 => IncludedN n x y\n\nsyntax:max \"<affine> \" term:40 : term\n\nsyntax:max \"β–‘ \" term:40 : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|==> $P)) => ``(BUpd.bupd iprop($P))\n | `(iprop($P ==βˆ— $Q)) => ``(BIBase.wand iprop($P) (BUpd.bupd iprop($Q)))\n\ndelab_rule BUpd.bupd\n | `($_ $P) => do ``(iprop(|==> $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 , $E2 }=> $P)) => ``(FUpd.fupd $E1 $E2 iprop($P))\n | `(iprop($P ={ $E1 , $E2 }=βˆ— $Q)) => ``(BIBase.wand iprop($P) (FUpd.fupd $E1 $E2 iprop($Q)))\n | `(iprop(|={ $E1 }=> $P)) => ``(FUpd.fupd $E1 $E1 iprop($P))\n | `(iprop($P ={ $E1 }=βˆ— $Q)) => ``(BIBase.wand iprop($P) (FUpd.fupd $E1 $E1 iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 }[ $E2 ]β–·=> $P)) => ``(iprop(|={$E1, $E2}=> β–· (|={ $E2, $E1 }=> iprop($P))))\n | `(iprop($P ={ $E1 }[ $E2 ]β–·=βˆ— $Q)) => ``(iprop(iprop($P) -βˆ— |={$E1}[$E2]β–·=> iprop($Q)))\n | `(iprop(|={ $E1 }β–·=> $P)) => ``(iprop(|={$E1}[$E1]β–·=> iprop($P)))\n | `(iprop($P ={ $E1 }β–·=βˆ— $Q)) => ``(iprop(iprop($P) ={$E1}[$E1]β–·=βˆ— iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(|={ $E1 }[ $E2 ]β–·^$n=> $P)) => ``(iprop(|={$E1, $E2}=> β–·^[$n] (|={ $E2, $E1 }=> iprop($P))))\n | `(iprop($P ={ $E1 }[ $E2 ]β–·^$n=βˆ— $Q)) => ``(iprop(iprop($P) -βˆ— |={$E1}[$E2]β–·^$n=> iprop($Q)))\n | `(iprop(|={ $E1 }β–·^$n=> $P)) => ``(iprop(|={$E1}[$E1]β–·^$n=> iprop($P)))\n | `(iprop($P ={ $E1 }β–·^$n=βˆ— $Q)) => ``(iprop(iprop($P) ={$E1}[$E1]β–·^$n=βˆ— iprop($Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–  $P)) => ``(Plainly.plainly iprop($P))\n\ndelab_rule Plainly.plainly\n | `($_ $P) => do ``(iprop(β–  $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β– ? $p $P)) => ``(Plainly.plainlyIf $p iprop($P))\n\ndelab_rule Plainly.plainlyIf\n | `($_ $p $P) => do ``(iprop(β– ? $p $(← Iris.BI.unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "unpackIprop", "content": "partial def unpackIprop [Monad m] [MonadRef m] [MonadQuotation m] : Term β†’ m Term\n | `(iprop($P)) => do `($P)\n | `($P:ident) => do `($P)\n | `(?$P:ident) => do `(?$P)\n | `(($P)) => do `(($(← unpackIprop P)))\n | `($P $[ $Q]*) => do ``($P $[ $Q]*)\n | `(if $c then $t else $e) => do\n let t ← unpackIprop t\n let e ← unpackIprop e\n `(if $c then $t else $e)\n | `(($P : $t)) => do ``(($(← unpackIprop P) : $t))\n | `($t) => `($t:term)" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/\n\n and_ne : OFE.NonExpansiveβ‚‚ and\n or_ne : OFE.NonExpansiveβ‚‚ or\n imp_ne : OFE.NonExpansiveβ‚‚ imp\n sForall_ne {P₁ Pβ‚‚} : liftRel (Β· ≑{n}≑ Β·) P₁ Pβ‚‚ β†’ sForall P₁ ≑{n}≑ sForall Pβ‚‚\n sExists_ne {P₁ Pβ‚‚} : liftRel (Β· ≑{n}≑ Β·) P₁ Pβ‚‚ β†’ sExists P₁ ≑{n}≑ sExists Pβ‚‚\n sep_ne : OFE.NonExpansiveβ‚‚ sep\n wand_ne : OFE.NonExpansiveβ‚‚ wand\n persistently_ne : OFE.NonExpansive persistently\n later_ne : OFE.NonExpansive later\n\n pure_intro {Ο† : Prop} {P : PROP} : Ο† β†’ P ⊒ βŒœΟ†βŒ\n pure_elim' {Ο† : Prop} {P : PROP} : (Ο† β†’ True ⊒ P) β†’ βŒœΟ†βŒ ⊒ P\n\n and_elim_l {P Q : PROP} : P ∧ Q ⊒ P\n and_elim_r {P Q : PROP} : P ∧ Q ⊒ Q\n and_intro {P Q R : PROP} : (P ⊒ Q) β†’ (P ⊒ R) β†’ P ⊒ Q ∧ R\n\n or_intro_l {P Q : PROP} : P ⊒ P ∨ Q\n or_intro_r {P Q : PROP} : Q ⊒ P ∨ Q\n or_elim {P Q R : PROP} : (P ⊒ R) β†’ (Q ⊒ R) β†’ P ∨ Q ⊒ R\n\n imp_intro {P Q R : PROP} : (P ∧ Q ⊒ R) β†’ P ⊒ Q β†’ R\n imp_elim {P Q R : PROP} : (P ⊒ Q β†’ R) β†’ P ∧ Q ⊒ R\n\n sForall_intro {P : PROP} {Ξ¨ : PROP β†’ Prop} : (βˆ€ p, Ξ¨ p β†’ P ⊒ p) β†’ P ⊒ sForall Ξ¨\n sForall_elim {Ξ¨ : PROP β†’ Prop} {p : PROP} : Ξ¨ p β†’ sForall Ξ¨ ⊒ p\n\n sExists_intro {Ξ¨ : PROP β†’ Prop} {p : PROP} : Ξ¨ p β†’ p ⊒ sExists Ξ¨\n sExists_elim {Ξ¦ : PROP β†’ Prop} {Q : PROP} : (βˆ€ p, Ξ¦ p β†’ p ⊒ Q) β†’ sExists Ξ¦ ⊒ Q\n\n sep_mono {P P' Q Q' : PROP} : (P ⊒ Q) β†’ (P' ⊒ Q') β†’ P βˆ— P' ⊒ Q βˆ— Q'\n emp_sep {P : PROP} : emp βˆ— P ⊣⊒ P\n sep_symm {P Q : PROP} : P βˆ— Q ⊒ Q βˆ— P\n sep_assoc_l {P Q R : PROP} : (P βˆ— Q) βˆ— R ⊒ P βˆ— (Q βˆ— R)\n\n wand_intro {P Q R : PROP} : (P βˆ— Q ⊒ R) β†’ P ⊒ Q -βˆ— R\n wand_elim {P Q R : PROP} : (P ⊒ Q -βˆ— R) β†’ P βˆ— Q ⊒ R\n\n persistently_mono {P Q : PROP} : (P ⊒ Q) β†’ <pers> P ⊒ <pers> Q\n persistently_idem_2 {P : PROP} : <pers> P ⊒ <pers> <pers> P\n persistently_emp_2 : (emp : PROP) ⊒ <pers> emp\n persistently_and_2 {P Q : PROP} : (<pers> P) ∧ (<pers> Q) ⊒ <pers> (P ∧ Q)\n persistently_sExists_1 {Ξ¨ : PROP β†’ Prop} : <pers> (sExists Ξ¨) ⊒ βˆƒ p, ⌜Ψ p⌝ ∧ <pers> p\n persistently_absorb_l {P Q : PROP} : <pers> P βˆ— Q ⊒ <pers> P\n persistently_and_l {P Q : PROP} : <pers> P ∧ Q ⊒ P βˆ— Q\n\n later_mono {P Q : PROP} : (P ⊒ Q) β†’ β–· P ⊒ β–· Q\n later_intro {P : PROP} : P ⊒ β–· P\n\n later_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–· p) ⊒ β–· sForall Ξ¦\n later_sExists_false {Ξ¦ : PROP β†’ Prop} : (β–· sExists Ξ¦) ⊒ β–· False ∨ βˆƒ p, ⌜Φ p⌝ ∧ β–· p\n later_sep {P Q : PROP} : β–· (P βˆ— Q) ⊣⊒ β–· P βˆ— β–· Q\n later_persistently {P : PROP} : β–· <pers> P ⊣⊒ <pers> β–· P\n later_false_em {P : PROP} : β–· P ⊒ β–· False ∨ (β–· False β†’ P)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "Included", "content": "def Included (x y : Ξ±) : Prop := βˆƒ z, y ≑ x β€’ z" }, { "name": "CMRA", "content": "class CMRA (Ξ± : Type _) extends OFE Ξ± where\n pcore : Ξ± β†’ Option Ξ±\n op : Ξ± β†’ Ξ± β†’ Ξ±\n ValidN : Nat β†’ Ξ± β†’ Prop\n Valid : Ξ± β†’ Prop\n\n op_ne : NonExpansive (op x)\n pcore_ne : x ≑{n}≑ y β†’ pcore x = some cx β†’\n βˆƒ cy, pcore y = some cy ∧ cx ≑{n}≑ cy\n validN_ne : x ≑{n}≑ y β†’ ValidN n x β†’ ValidN n y\n\n valid_iff_validN : Valid x ↔ βˆ€ n, ValidN n x\n validN_succ : ValidN n.succ x β†’ ValidN n x\n validN_op_left : ValidN n (op x y) β†’ ValidN n x\n\n assoc : op x (op y z) ≑ op (op x y) z\n comm : op x y ≑ op y x\n\n pcore_op_left : pcore x = some cx β†’ op cx x ≑ x\n pcore_idem : pcore x = some cx β†’ pcore cx ≑ some cx\n pcore_op_mono : pcore x = some cx β†’ βˆ€ y, βˆƒ cy, pcore (op x y) ≑ some (op cx cy)\n\n extend : ValidN n x β†’ x ≑{n}≑ op y₁ yβ‚‚ β†’\n Ξ£' z₁ zβ‚‚, x ≑ op z₁ zβ‚‚ ∧ z₁ ≑{n}≑ y₁ ∧ zβ‚‚ ≑{n}≑ yβ‚‚" }, { "name": "Commutative", "content": "class Commutative (R : Relation Ξ±) (f : Ξ² β†’ Ξ² β†’ Ξ±) where\n comm {x y : Ξ²} : R (f x y) (f y x)" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "Absorbing", "content": "class Absorbing [BI PROP] (P : PROP) where\n absorbing : <absorb> P ⊒ P" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "", "content": "instance : BIPlainly (UPred M) where\n mono H _ _ _ := H _ _ CMRA.unit_validN\n elim_persistently {P} n x Hx := by admit /- proof elided -/" }, { "name": "persistently", "content": "protected def persistently (P : UPred M) : UPred M where\n holds n x := P n (CMRA.core x)\n mono H Hx Hn := P.mono H (CMRA.core_incN_core Hx) Hn" }, { "name": "BIUpdate", "content": "class BIUpdate (PROP : Type _) [BI PROP] extends BUpd PROP where\n [bupd_ne : OFE.NonExpansive (BUpd.bupd (PROP := PROP))]\n intro {P : PROP} : iprop(P ⊒ |==> P)\n mono {P Q : PROP} : iprop(P ⊒ Q) β†’ iprop(|==> P ⊒ |==> Q)\n trans {P : PROP} : iprop(|==> |==> P ⊒ |==> P)\n frame_r {P R : PROP} : iprop((|==> P) βˆ— R ⊒ |==> (P βˆ— R))" }, { "name": "UPred", "content": "@[ext]\nstructure UPred (M : Type _) [UCMRA M] where\n holds : Nat β†’ M β†’ Prop\n mono {n1 n2 x1 x2} : holds n1 x1 β†’ x1 β‰Ό{n2} x2 β†’ n2 ≀ n1 β†’ holds n2 x2" }, { "name": "IsModal", "content": "class IsModal [BI PROP1] [BI PROP2] (M : PROP1 β†’ PROP2)\n (iaction saction : ModalityAction PROP1 PROP2) where\n spec_intuitionistic : iaction.intuitionistic_action_spec M\n spec_spatial : saction.spatial_action_spec M\n emp : iprop(emp) ⊒ M iprop(emp)\n mono : βˆ€ {P Q}, (P ⊒ Q) β†’ M P ⊒ M Q\n sep : βˆ€ {P Q}, iprop(M P βˆ— M Q) ⊒ M iprop(P βˆ— Q)" }, { "name": "core", "content": "def core (x : Ξ±) := (pcore x).getD x" }, { "name": "UCMRA", "content": "class UCMRA (Ξ± : Type _) extends CMRA Ξ± where\n unit : Ξ±\n unit_valid : βœ“ unit\n unit_left_id : unit β€’ x ≑ x\n pcore_unit : pcore unit ≑ some unit" }, { "name": "pcore", "content": "def pcore : DFrac F β†’ Option (DFrac F)\n | own _ => none\n | .discard => some discard\n | ownDiscard _ => some discard" }, { "name": "DFrac", "content": "inductive DFrac (F : Type _) where\n \n| own (f : F) : DFrac F\n \n| discard : DFrac F\n \n| ownDiscard (f : F) : DFrac F" }, { "name": "op", "content": "def op : DFrac F β†’ DFrac F β†’ DFrac F\n | .discard, .discard => discard\n | own f, .discard\n | ownDiscard f, .discard\n | .discard, own f\n | .discard, ownDiscard f => ownDiscard f\n | own f, own f' => own (f + f')\n | own f, ownDiscard f'\n | ownDiscard f, own f'\n | ownDiscard f, ownDiscard f' => ownDiscard (f + f')" }, { "name": "Associative", "content": "class Associative (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n assoc {x y z : Ξ±} : R (f (f x y) z) (f x (f y z))" }, { "name": "plainly", "content": "protected def plainly (P : UPred M) : UPred M where\n holds n _ := P n UCMRA.unit\n mono H _ Hn := P.mono H (CMRA.incN_refl UCMRA.unit) Hn" }, { "name": "BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "Idempotent", "content": "class Idempotent (R : Relation Ξ±) (f : Ξ± β†’ Ξ± β†’ Ξ±) where\n idem {x : Ξ±} : R (f x x) x" }, { "name": "", "content": "instance : BIPlainlyExists (UPred M) where\n plainly_sExists_1 _ _ _ := fun ⟨_, hp⟩ => ⟨_, ⟨_, rfl⟩, hp⟩" }, { "name": "BIPlainlyExists", "content": "class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where\n plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p" }, { "name": "", "content": "instance : Plainly (UPred M) := ⟨UPred.plainly⟩" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" }, { "name": "infix:60 \" β€’ \" => op", "content": "infix:60 \" β€’ \" => op" }, { "name": "infix:50 \" β‰Ό \" => Included", "content": "infix:50 \" β‰Ό \" => Included" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "persistently_and_sep_assoc", "content": "theorem persistently_and_sep_assoc [BI PROP] {P Q R : PROP} :\n <pers> P ∧ (Q βˆ— R) ⊣⊒ (<pers> P ∧ Q) βˆ— R" }, { "name": "and_mono_l", "content": "theorem and_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P ∧ Q ⊒ P' ∧ Q" }, { "name": "and_mono", "content": "@[rw_mono_rule]\ntheorem and_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P ∧ P' ⊒ Q ∧ Q'" }, { "name": "and_elim_r'", "content": "theorem and_elim_r' [BI PROP] {P Q R : PROP} (h : Q ⊒ R) : P ∧ Q ⊒ R" }, { "name": "and_elim_l'", "content": "theorem and_elim_l' [BI PROP] {P Q R : PROP} (h : P ⊒ R) : P ∧ Q ⊒ R" }, { "name": "sep_assoc", "content": "theorem sep_assoc [BI PROP] {P Q R : PROP} : (P βˆ— Q) βˆ— R ⊣⊒ P βˆ— Q βˆ— R" }, { "name": "sep_congr_l", "content": "theorem sep_congr_l [BI PROP] {P P' Q : PROP} (h : P ⊣⊒ P') : P βˆ— Q ⊣⊒ P' βˆ— Q" }, { "name": "sep_congr", "content": "@[rw_mono_rule]\ntheorem sep_congr [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊣⊒ Q) (h2 : P' ⊣⊒ Q') :\n (P βˆ— P') ⊣⊒ (Q βˆ— Q')" }, { "name": "sep_congr_r", "content": "theorem sep_congr_r [BI PROP] {P Q Q' : PROP} (h : Q ⊣⊒ Q') : P βˆ— Q ⊣⊒ P βˆ— Q'" }, { "name": "sep_mono_l", "content": "theorem sep_mono_l [BI PROP] {P P' Q : PROP} (h : P ⊒ P') : P βˆ— Q ⊒ P' βˆ— Q" }, { "name": "BIBase.Entails.rfl", "content": "@[simp] theorem BIBase.Entails.rfl [BI PROP] {P : PROP} : P ⊒ P" }, { "name": "Included.trans", "content": "theorem Included.trans : (x : Ξ±) β‰Ό y β†’ y β‰Ό z β†’ x β‰Ό z" }, { "name": "inc_trans", "content": "theorem inc_trans {x y z : Ξ±} : x β‰Ό y β†’ y β‰Ό z β†’ x β‰Ό z" }, { "name": "op_left_eqv", "content": "theorem op_left_eqv {x y : Ξ±} (z : Ξ±) (e : x ≑ y) : x β€’ z ≑ y β€’ z" }, { "name": "_root_.Iris.OFE.Dist.op_r", "content": "theorem _root_.Iris.OFE.Dist.op_r {x y z : Ξ±} : y ≑{n}≑ z β†’ x β€’ y ≑{n}≑ x β€’ z" }, { "name": "op_right_dist", "content": "theorem op_right_dist (x : Ξ±) {y z : Ξ±} (e : y ≑{n}≑ z) : x β€’ y ≑{n}≑ x β€’ z" }, { "name": "_root_.Iris.OFE.Equiv.op_r", "content": "theorem _root_.Iris.OFE.Equiv.op_r {x y z : Ξ±} : y ≑ z β†’ x β€’ y ≑ x β€’ z" }, { "name": "op_right_eqv", "content": "theorem op_right_eqv (x : Ξ±) {y z : Ξ±} (e : y ≑ z) : x β€’ y ≑ x β€’ z" }, { "name": "IncludedN.trans", "content": "theorem IncludedN.trans : (x : Ξ±) β‰Ό{n} y β†’ y β‰Ό{n} z β†’ x β‰Ό{n} z" }, { "name": "incN_trans", "content": "theorem incN_trans {x y z : Ξ±} : x β‰Ό{n} y β†’ y β‰Ό{n} z β†’ x β‰Ό{n} z" }, { "name": "op_left_dist", "content": "theorem op_left_dist {x y : Ξ±} (z : Ξ±) (e : x ≑{n}≑ y) : x β€’ z ≑{n}≑ y β€’ z" }, { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" }, { "name": "and_self", "content": "theorem and_self [BI PROP] {P : PROP} : P ∧ P ⊣⊒ P" }, { "name": "emp_sep", "content": "theorem emp_sep [BI PROP] {P : PROP} : emp βˆ— P ⊣⊒ P" }, { "name": "sep_mono_r", "content": "theorem sep_mono_r [BI PROP] {P Q Q' : PROP} (h : Q ⊒ Q') : P βˆ— Q ⊒ P βˆ— Q'" }, { "name": "sep_mono", "content": "@[rw_mono_rule]\ntheorem sep_mono [BI PROP] {P P' Q Q' : PROP} (h1 : P ⊒ Q) (h2 : P' ⊒ Q') : P βˆ— P' ⊒ Q βˆ— Q'" }, { "name": "sep_comm", "content": "theorem sep_comm [BI PROP] {P Q : PROP} : P βˆ— Q ⊣⊒ Q βˆ— P" }, { "name": "sep_elim_r", "content": "theorem sep_elim_r [BI PROP] {P Q : PROP} [TCOr (Affine P) (Absorbing Q)] : P βˆ— Q ⊒ Q" }, { "name": "absorbingly_of_persistently", "content": "theorem absorbingly_of_persistently [BI PROP] {P : PROP} : <pers> P ⊒ <absorb> P" }, { "name": "persistently_elim", "content": "theorem persistently_elim [BI PROP] {P : PROP} [Absorbing P] : <pers> P ⊒ P" }, { "name": "persistently_entails_r", "content": "theorem persistently_entails_r [BI PROP] {P Q : PROP} (h : P ⊒ <pers> Q) : P ⊒ P βˆ— <pers> Q" } ]
[ { "name": "Iris.Plainly", "content": "class Plainly (PROP : Type _) where\n plainly : PROP β†’ PROP" }, { "name": "Iris.Plainly.plainlyIf", "content": "def Plainly.plainlyIf [Iris.BI.BIBase PROP] [Plainly PROP] (p : Bool) (P : PROP) : PROP :=\n iprop(if p then β–  P else P)" }, { "name": "Iris.BIPlainly", "content": "class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where\n [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))]\n mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q\n elim_persistently {P : PROP} : β–  P ⊒ <pers> P\n idem {P : PROP} : β–  P ⊒ β–  β–  P\n plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦\n plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q)\n emp_intro {P : PROP} : P ⊒ β–  emp\n plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P\n later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P" }, { "name": "Iris.BIPlainlyExists", "content": "class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where\n plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p" } ]
[ { "name": "Iris.BI.persistently_elim_plainly", "content": "theorem persistently_elim_plainly : <pers> β–  P ⊣⊒ β–  P" }, { "name": "Iris.BI.plainly_and_sep_assoc", "content": "theorem plainly_and_sep_assoc : β–  P ∧ (Q βˆ— R) ⊣⊒ (β–  P ∧ Q) βˆ— R" } ]
import Iris.BI.Classes import Iris.BI.BI import Iris.BI.DerivedLaws import Iris.Algebra namespace Iris open BI class Plainly (PROP : Type _) where plainly : PROP β†’ PROP def Plainly.plainlyIf [Iris.BI.BIBase PROP] [Plainly PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–  P else P) class BIPlainly (PROP : Type _) [Iris.BI PROP] extends Plainly PROP where [ne : Iris.OFE.NonExpansive (Plainly.plainly (PROP := PROP))] mono {P Q : PROP} : (P ⊒ Q) β†’ β–  P ⊒ β–  Q elim_persistently {P : PROP} : β–  P ⊒ <pers> P idem {P : PROP} : β–  P ⊒ β–  β–  P plainly_sForall_2 {Ξ¦ : PROP β†’ Prop} : (βˆ€ p, ⌜Φ p⌝ β†’ β–  p) ⊒ β–  sForall Ξ¦ plainly_impl_plainly {P Q : PROP} : (β–  P β†’ β–  Q) ⊒ β–  (β–  P β†’ Q) emp_intro {P : PROP} : P ⊒ β–  emp plainly_absorb {P Q : PROP} : β–  P βˆ— Q ⊒ β–  P later_plainly {P : PROP} : β–· β–  P ⊣⊒ β–  β–· P class BIPlainlyExists (PROP : Type _) [Iris.BI PROP] [BIPlainly PROP] where plainly_sExists_1 {Ξ¦ : PROP β†’ Prop} : β–  sExists Ξ¦ ⊒ βˆƒ p, ⌜Φ p⌝ ∧ β–  p namespace BI open Iris.Std section PlainlyLaws open BIPlainly variable [BI PROP] [BIPlainly PROP] variable {P Q R : PROP}
theorem plainly_sep_dup : β–  P ⊣⊒ β–  P βˆ— β–  P :=
:= by refine ⟨?_, plainly_absorb⟩ refine and_self.2.trans ?_ refine ((and_mono .rfl emp_sep.2).trans plainly_and_sep_assoc.1).trans ?_ exact (sep_mono and_elim_l .rfl).trans .rfl
6
72
false
Framework
244
Iris.BI.later_and
theorem later_and [BI PROP] {P Q : PROP} : β–· (P ∧ Q) ⊣⊒ β–· P ∧ β–· Q
iris-lean
src/Iris/BI/DerivedLaws.lean
[ "import Iris.BI.Extensions", "import Iris.Std.TC", "import Iris.Std.Classes", "import Iris.BI.BI", "import src.Iris.Algebra.OFE", "import src.Iris.BI.BI", "import Iris.BI.Classes", "import Iris.Std.Rewrite" ]
[ { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.merge", "module": "Init.Data.Option.Basic" }, { "name": "id", "module": "Init.Prelude" }, { "name": "Equivalence", "module": "Init.Core" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "m", "module": "QqTest.matching" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do", "content": "macro \"βˆƒ\" xs:explicitBinders \", \" b:term : term => do\n return βŸ¨β† expandExplicitBinders ``BIBase.exists xs b⟩" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y\n\nsyntax:max \"<pers> \" term:40 : term" }, { "name": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entai", "content": "macro:25 P:term:29 \" ⊒ \" Q:term:25 : term => ``(BIBase.Entails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊒ $(← unpackIprop Q))" }, { "name": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails i", "content": "macro:25 P:term:29 \" ⊣⊒ \" Q:term:29 : term => ``(BiEntails iprop($P) iprop($Q))\n\ndelab_rule BIBase.Entails\n | `($_ iprop(emp) $P) => do ``(⊒ $(← unpackIprop P))\n\ndelab_rule BIBase.BiEntails\n | `($_ $P $Q) => do ``($(← unpackIprop P) ⊣⊒ $(← unpackIprop Q))\n\nsyntax \"⌜\" term \"⌝\" : term\n\nsyntax:max \"β–· \" term:40 : term" }, { "name": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((ipro", "content": "macro:max \"iprop(\" P:term \" : \" t:term \")\" : term => `((iprop($P) : $t))\n\nsyntax:max \"iprop(\" term \")\" : term\n\nsyntax:max \"<affine> \" term:40 : term\n\nsyntax:max \"β–‘ \" term:40 : term\n\nsyntax:max \"<absorb> \" term:40 : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(term($t))) => pure t\n | `(iprop($t)) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(($P))) => ``((iprop($P)))\n | `(iprop(if $c then $t else $e)) => ``(if $c then iprop($t) else iprop($e))\n | `(iprop(($P : $t))) => ``((iprop($P) : $t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(emp)) => ``(BIBase.emp)\n | `(iprop(⌜$Ο†βŒ)) => ``(BIBase.pure $Ο†)\n | `(iprop($P ∧ $Q)) => ``(BIBase.and iprop($P) iprop($Q))\n | `(iprop($P ∨ $Q)) => ``(BIBase.or iprop($P) iprop($Q))\n | `(iprop($P β†’ $Q)) => ``(BIBase.imp iprop($P) iprop($Q))\n | `(iprop(βˆƒ $xs, $Ξ¨)) => do expandExplicitBinders ``BIBase.exists xs (← ``(iprop($Ξ¨)))\n | `(iprop($P βˆ— $Q)) => ``(BIBase.sep iprop($P) iprop($Q))\n | `(iprop($P -βˆ— $Q)) => ``(BIBase.wand iprop($P) iprop($Q))\n | `(iprop(<pers> $P)) => ``(BIBase.persistently iprop($P))\n | `(iprop(β–· $P)) => ``(BIBase.later iprop($P))\n\ndelab_rule BIBase.emp\n | `($_) => ``(iprop($(mkIdent `emp)))\ndelab_rule BIBase.pure\n | `($_ $Ο†) => ``(iprop(⌜$Ο†βŒ))\ndelab_rule BIBase.and\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∧ $(← unpackIprop Q)))\ndelab_rule BIBase.or\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ∨ $(← unpackIprop Q)))\ndelab_rule BIBase.imp\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) β†’ $(← unpackIprop Q)))\ndelab_rule BIBase.forall\n | `($_ fun $x:ident => iprop(βˆ€ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆ€ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆ€ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.exists\n | `($_ fun $x:ident => iprop(βˆƒ $y:ident $[$z:ident]*, $Ξ¨)) => do\n ``(iprop(βˆƒ $x:ident $y:ident $[$z:ident]*, $Ξ¨))\n | `($_ fun $x:ident => $Ξ¨) => do ``(iprop(βˆƒ $x:ident, $(← unpackIprop Ξ¨)))\ndelab_rule BIBase.sep\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.wand\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) -βˆ— $(← unpackIprop Q)))\ndelab_rule BIBase.persistently\n | `($_ $P) => do ``(iprop(<pers> $(← unpackIprop P)))\n\ndelab_rule BIBase.pure\n | `($_ True) => ``(iprop($(mkIdent `True)))\n | `($_ False) => ``(iprop($(mkIdent `False)))\ndelab_rule BIBase.imp\n | `($_ $P iprop(False)) => do ``(iprop(Β¬$(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ _%$tk, $Ξ¨)) => ``(BIBase.forall (fun _%$tk => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x:ident, $Ξ¨)) => ``(BIBase.forall (fun $x => iprop($Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ (_%$tk : $t), $Ξ¨)) => ``(BIBase.forall (fun (_%$tk : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ (_%$tk $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun (_%$tk : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ ($x:ident : $t), $Ξ¨)) => ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ ($x:ident $xs* : $t), $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ ($xs* : $t), $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {_%$tk : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop($Ξ¨)))\n | `(iprop(βˆ€ {_%$tk $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun {_%$tk : $t} => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ {$x:ident : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop($Ξ¨)))\n | `(iprop(βˆ€ {$x:ident $xs* : $t}, $Ξ¨)) =>\n ``(BIBase.forall (fun ($x : $t) => iprop(βˆ€ {$xs* : $t}, $Ξ¨)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(βˆ€ $x $y $xs*, $Ξ¨)) => ``(iprop(βˆ€ $x, βˆ€ $y $xs*, $Ξ¨))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(True)) => ``(BIBase.pure True)\n | `(iprop(False)) => ``(BIBase.pure False)\n | `(iprop(Β¬$P)) => ``(iprop($P β†’ False))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop($P ↔ $Q)) => ``(iff iprop($P) iprop($Q))\n | `(iprop($P βˆ—-βˆ— $Q)) => ``(wandIff iprop($P) iprop($Q))\n\ndelab_rule iff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) ↔ $(← unpackIprop Q)))\ndelab_rule wandIff\n | `($_ $P $Q) => do ``(iprop($(← unpackIprop P) βˆ—-βˆ— $(← unpackIprop Q)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<affine> $P)) => ``(affinely iprop($P))\n | `(iprop(<absorb> $P)) => ``(absorbingly iprop($P))\n\ndelab_rule affinely\n | `($_ $P) => do ``(iprop(<affine> $(← unpackIprop P)))\ndelab_rule absorbingly\n | `($_ $P) => do ``(iprop(<absorb> $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–‘ $P)) => ``(intuitionistically iprop($P))\n\ndelab_rule intuitionistically\n | `($_ $P) => do ``(iprop(β–‘ $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(<pers>?$p $P)) => ``(persistentlyIf $p iprop($P))\n | `(iprop(<affine>?$p $P)) => ``(affinelyIf $p iprop($P))\n | `(iprop(<absorb>?$p $P)) => ``(absorbinglyIf $p iprop($P))\n | `(iprop(β–‘?$p $P)) => ``(intuitionisticallyIf $p iprop($P))\n\ndelab_rule persistentlyIf\n | `($_ $p $P) => do ``(iprop(<pers>?$p $(← unpackIprop P)))\ndelab_rule affinelyIf\n | `($_ $p $P) => do ``(iprop(<affine>?$p $(← unpackIprop P)))\ndelab_rule absorbinglyIf\n | `($_ $p $P) => do ``(iprop(<absorb>?$p $(← unpackIprop P)))\ndelab_rule intuitionisticallyIf\n | `($_ $p $P) => do ``(iprop(β–‘?$p $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β–·^[$n] $P)) => ``(laterN $n iprop($P))\n\ndelab_rule laterN\n | `($_ $n $P) => do ``(iprop(β–·^[$n] $(← unpackIprop P)))" }, { "name": "macro_rules", "content": "macro_rules\n | `(iprop(β—‡ $P)) => ``(except0 iprop($P))\n\ndelab_rule except0\n | `($_ $P) => do ``(iprop(β—‡ $(← unpackIprop P)))" }, { "name": "BIBase", "content": "class BIBase (PROP : Type u) where\n Entails : PROP β†’ PROP β†’ Prop\n emp : PROP\n pure : Prop β†’ PROP\n and : PROP β†’ PROP β†’ PROP\n or : PROP β†’ PROP β†’ PROP\n imp : PROP β†’ PROP β†’ PROP\n sForall : (PROP β†’ Prop) β†’ PROP\n sExists : (PROP β†’ Prop) β†’ PROP\n sep : PROP β†’ PROP β†’ PROP\n wand : PROP β†’ PROP β†’ PROP\n persistently : PROP β†’ PROP\n later : PROP β†’ PROP" }, { "name": "BI", "content": "class BI (PROP : Type _) extends COFE PROP, BI.BIBase PROP where\n Equiv P Q := P ⊣⊒ Q\n\n entails_preorder : Preorder Entails\n equiv_iff {P Q : PROP} : (P ≑ Q) ↔ P ⊣⊒ Q := by admit /- proof elided -/" }, { "name": "liftRel", "content": "def liftRel (R : Ξ± β†’ Ξ² β†’ Prop) (A : Ξ± β†’ Prop) (B : Ξ² β†’ Prop) : Prop :=\n (βˆ€ a, A a β†’ βˆƒ b, B b ∧ R a b) ∧ (βˆ€ b, B b β†’ βˆƒ a, A a ∧ R a b)" }, { "name": "Preorder", "content": "class Preorder (R : Relation Ξ±) extends Reflexive R, Transitive R" }, { "name": "Reflexive", "content": "class Reflexive (R : Relation Ξ±) where\n refl {x : Ξ±} : R x x" }, { "name": "Relation", "content": "abbrev Relation (Ξ± : Type _) := Ξ± β†’ Ξ± β†’ Prop" }, { "name": "Transitive", "content": "class Transitive (R : Relation Ξ±) where\n trans {x y z : Ξ±} : R x y β†’ R y z β†’ R x z" }, { "name": "NonExpansiveβ‚‚", "content": "class NonExpansiveβ‚‚ [OFE Ξ±] [OFE Ξ²] [OFE Ξ³] (f : Ξ± β†’ Ξ² β†’ Ξ³) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ βˆ€ ⦃y₁ y₂⦄, y₁ ≑{n}≑ yβ‚‚ β†’ f x₁ y₁ ≑{n}≑ f xβ‚‚ yβ‚‚" }, { "name": "OFE.ContractiveHom.fixpoint_ne", "content": "instance OFE.ContractiveHom.fixpoint_ne [COFE Ξ±] [Inhabited Ξ±] :\n NonExpansive (ContractiveHom.fixpoint (Ξ± := Ξ±)) where\n ne n f1 f2 H := by admit /- proof elided -/" }, { "name": "ContractiveHom", "content": "@[ext] structure ContractiveHom (Ξ± Ξ² : Type _) [OFE Ξ±] [OFE Ξ²] extends Hom Ξ± Ξ² where\n [contractive : Contractive f]\n ne := ne_of_contractive f" }, { "name": "OFE.Option.some.ne", "content": "instance OFE.Option.some.ne [OFE Ξ±] : OFE.NonExpansive (some : Ξ± β†’ Option Ξ±) := ⟨fun _ _ _ => id⟩" }, { "name": "Option.merge_ne", "content": "instance Option.merge_ne [OFE Ξ±] {op : Ξ± β†’ Ξ± β†’ Ξ±} [NonExpansiveβ‚‚ op] :\n NonExpansiveβ‚‚ (Option.merge op) where\n ne n x1 x2 Hx y1 y2 Hy := by admit /- proof elided -/" }, { "name": "NonExpansive", "content": "class NonExpansive [OFE Ξ±] [OFE Ξ²] (f : Ξ± β†’ Ξ²) where\n ne : βˆ€ ⦃n x₁ x₂⦄, x₁ ≑{n}≑ xβ‚‚ β†’ f x₁ ≑{n}≑ f xβ‚‚" }, { "name": "COFE.OFunctor.constOF_RFunctor", "content": "instance COFE.OFunctor.constOF_RFunctor [CMRA B] : RFunctor (constOF B) where\n map f g := by admit /- proof elided -/" }, { "name": "IsCOFE", "content": "class IsCOFE (Ξ± : Type _) [OFE Ξ±] where\n compl : Chain Ξ± β†’ Ξ±\n conv_compl {c : Chain Ξ±} : compl c ≑{n}≑ c n" }, { "name": "Chain", "content": "structure Chain (Ξ± : Type _) [OFE Ξ±] where\n chain : Nat β†’ Ξ±\n cauchy : n ≀ i β†’ chain i ≑{n}≑ chain n" }, { "name": "LawfulBigOp", "content": "class LawfulBigOp (f : PROP β†’ PROP β†’ PROP) (unit : outParam PROP)\n (eq : outParam (PROP β†’ PROP β†’ Prop)) where\n refl : eq a a\n symm : eq a b β†’ eq b a\n trans : eq a b β†’ eq b c β†’ eq a c\n comm : eq (f a b) (f b a)\n assoc : eq (f (f a b) c) (f a (f b c))\n left_id : eq (f unit a) a\n congr_l : eq a a' β†’ eq (f a b) (f a' b)" }, { "name": "intuitionistically", "content": "def intuitionistically [BIBase PROP] (P : PROP) : PROP := iprop(<affine> <pers> P)" }, { "name": "Affine", "content": "class Affine [BI PROP] (P : PROP) where\n affine : P ⊒ emp" }, { "name": "bigAnd", "content": "def bigAnd [BIBase PROP] (Ps : List PROP) : PROP := bigOp and iprop(True) Ps" }, { "name": "bigOp", "content": "def bigOp (f : PROP β†’ PROP β†’ PROP) (unit : PROP) : List PROP β†’ PROP\n | [] => unit\n | [P] => P\n | P :: Ps => f P (bigOp f unit Ps)" }, { "name": "absorbingly", "content": "def absorbingly [BIBase PROP] (P : PROP) : PROP := iprop(True βˆ— P)" }, { "name": "BiEntails", "content": "structure BiEntails [BIBase PROP] (P Q : PROP) where\n mp : P ⊒ Q\n mpr : Q ⊒ P" }, { "name": "persistentlyIf", "content": "def persistentlyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <pers> P else P)" }, { "name": "intuitionisticallyIf", "content": "def intuitionisticallyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then β–‘ P else P)" }, { "name": "bigSep", "content": "def bigSep [BIBase PROP] (Ps : List PROP) : PROP := bigOp sep iprop(emp) Ps" }, { "name": "affinely", "content": "def affinely [BIBase PROP] (P : PROP) : PROP := iprop(emp ∧ P)" }, { "name": "bigOr", "content": "def bigOr [BIBase PROP] (Ps : List PROP) : PROP := bigOp or iprop(False) Ps" }, { "name": "absorbinglyIf", "content": "def absorbinglyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <absorb> P else P)" }, { "name": "affinelyIf", "content": "def affinelyIf [BIBase PROP] (p : Bool) (P : PROP) : PROP := iprop(if p then <affine> P else P)" }, { "name": "wandIff", "content": "def wandIff [BIBase PROP] (P Q : PROP) : PROP := iprop((P -βˆ— Q) ∧ (Q -βˆ— P))" }, { "name": "scoped infix:40 \" ≑ \" => OFE.Equiv", "content": "scoped infix:40 \" ≑ \" => OFE.Equiv" }, { "name": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y", "content": "scoped notation:40 x \" ≑{\" n \"}≑ \" y:41 => OFE.Dist n x y" }, { "name": "infixr:25 \" -c> \" => ContractiveHom", "content": "infixr:25 \" -c> \" => ContractiveHom" }, { "name": "notation:40 \"[∧] \" Ps:max => bigAnd Ps", "content": "notation:40 \"[∧] \" Ps:max => bigAnd Ps" }, { "name": "notation:40 \"[∨] \" Ps:max => bigOr Ps", "content": "notation:40 \"[∨] \" Ps:max => bigOr Ps" }, { "name": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps", "content": "notation:40 \"[βˆ—] \" Ps:max => bigSep Ps" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Dist.trans", "content": "theorem Dist.trans [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ z β†’ x ≑{n}≑ z" }, { "name": "BIBase.BiEntails.trans", "content": "theorem BIBase.BiEntails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊣⊒ Q) (h2 : Q ⊣⊒ R) : P ⊣⊒ R" }, { "name": "BIBase.Entails.trans", "content": "theorem BIBase.Entails.trans [BI PROP] {P Q R : PROP} (h1 : P ⊒ Q) (h2 : Q ⊒ R) : P ⊒ R" }, { "name": "Equiv.trans", "content": "theorem Equiv.trans [OFE Ξ±] {x : Ξ±} : x ≑ y β†’ y ≑ z β†’ x ≑ z" }, { "name": "equiv_eqv", "content": "theorem equiv_eqv [ofe : OFE Ξ±] : Equivalence ofe.Equiv" }, { "name": "Dist.symm", "content": "@[symm] theorem Dist.symm [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ y β†’ y ≑{n}≑ x" }, { "name": "Dist.rfl", "content": "@[simp, refl] theorem Dist.rfl [OFE Ξ±] {n} {x : Ξ±} : x ≑{n}≑ x" }, { "name": "DistLater.trans", "content": "theorem DistLater.trans [OFE Ξ±] {n} {x : Ξ±} (h1 : DistLater n x y) (h2 : DistLater n y z) :\n DistLater n x z" } ]
[]
[ { "name": "Iris.BI.and_symm", "content": "theorem and_symm [BI PROP] {P Q : PROP} : P ∧ Q ⊒ Q ∧ P" }, { "name": "Iris.BI.imp_intro'", "content": "theorem imp_intro' [BI PROP] {P Q R : PROP} (h : Q ∧ P ⊒ R) : P ⊒ Q β†’ R" }, { "name": "Iris.BI.imp_elim'", "content": "theorem imp_elim' [BI PROP] {P Q R : PROP} (h : Q ⊒ P β†’ R) : P ∧ Q ⊒ R" }, { "name": "Iris.BI.forall_intro", "content": "theorem forall_intro [BI PROP] {P : PROP} {Ξ¨ : Ξ± β†’ PROP} (h : βˆ€ a, P ⊒ Ξ¨ a) : P ⊒ βˆ€ a, Ξ¨ a" }, { "name": "Iris.BI.forall_elim", "content": "theorem forall_elim [BI PROP] {Ξ¨ : Ξ± β†’ PROP} (a : Ξ±) : (βˆ€ a, Ξ¨ a) ⊒ Ξ¨ a" }, { "name": "Iris.BI.forall_mono", "content": "@[rw_mono_rule]\ntheorem forall_mono [BI PROP] {Ξ¦ Ξ¨ : Ξ± β†’ PROP} (h : βˆ€ a, Ξ¦ a ⊒ Ξ¨ a) : (βˆ€ a, Ξ¦ a) ⊒ βˆ€ a, Ξ¨ a" }, { "name": "Iris.BI.and_self", "content": "theorem and_self [BI PROP] {P : PROP} : P ∧ P ⊣⊒ P" }, { "name": "Iris.BI.and_comm", "content": "theorem and_comm [BI PROP] {P Q : PROP} : P ∧ Q ⊣⊒ Q ∧ P" }, { "name": "Iris.BI.pure_elim", "content": "theorem pure_elim [BI PROP] (Ο† : Prop) {Q R : PROP} (h1 : Q ⊒ βŒœΟ†βŒ) (h2 : Ο† β†’ Q ⊒ R) : Q ⊒ R" }, { "name": "Iris.BI.and_forall_bool", "content": "theorem and_forall_bool [BI PROP] {P Q : PROP} :\n P ∧ Q ⊣⊒ Β«forallΒ» (fun b : Bool => if b then P else Q)" }, { "name": "Iris.BI.later_forall_2", "content": "theorem later_forall_2 [BI PROP] {Ξ±} {Ξ¦ : Ξ± β†’ PROP} : (βˆ€ a, β–· Ξ¦ a) ⊒ β–· βˆ€ a, Ξ¦ a" }, { "name": "Iris.BI.later_forall", "content": "theorem later_forall [BI PROP] {Ξ¦ : Ξ± β†’ PROP} :\n β–· (βˆ€ a, Ξ¦ a) ⊣⊒ (βˆ€ a, β–· Ξ¦ a)" } ]
import Iris.BI.Classes import Iris.BI.Extensions import Iris.BI.BI import Iris.Std.Classes import Iris.Std.Rewrite import Iris.Std.TC namespace Iris.BI open Iris.Std BI
theorem later_and [BI PROP] {P Q : PROP} : β–· (P ∧ Q) ⊣⊒ β–· P ∧ β–· Q :=
:= by constructor Β· refine (later_mono and_forall_bool.mp).trans ?_ refine .trans ?_ and_forall_bool.mpr refine (later_forall).mp.trans (forall_mono ?_) exact (Β·.casesOn .rfl .rfl) Β· refine .trans ?_ (later_mono and_forall_bool.mpr) refine and_forall_bool.mp.trans ?_ refine .trans (forall_mono ?_) later_forall.mpr exact (Β·.casesOn .rfl .rfl)
6
59
false
Framework
245
Juvix.Core.Main.Value.Approx.Indexed.preserved_step
lemma Value.Approx.Indexed.preserved_step {k} : (βˆ€ k' < k, Preservation k') β†’ Preservation k
juvix-lean
Juvix/Core/Main/Semantics/Approx/Indexed.lean
[ "import Juvix.Utils", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Mathlib.Tactic.Linarith", "import Mathlib.Data.List.Forall2", "import Juvix.Core.Main.Semantics.Eval", "import Aesop" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "List.map", "module": "Init.Prelude" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "reduceCtorEq", "module": "Lean.Meta.Tactic.Simp.BuiltinSimprocs.Core" }, { "name": "List.Forallβ‚‚.cons", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.nil", "module": "Batteries.Data.List.Basic" } ]
[ { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚\n\nsyntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))\n\nsyntax \"let \" ident \" := \" expr \" in \" expr : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Expr.Approx.Param", "content": "def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)" }, { "name": "Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "Eval.Indexed", "content": "inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where\n | var {n env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval.Indexed n env (Expr.var name idx) val\n | var_rec {n env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval.Indexed n env' expr val β†’\n Eval.Indexed n env (Expr.var name idx) val\n | unit {n env} :\n Eval.Indexed n env Expr.unit Value.unit\n | const {n env c} :\n Eval.Indexed n env (Expr.const c) (Value.const c)\n | constr {n env name} :\n Eval.Indexed n env (Expr.constr name) (Value.constr_app name [])\n | app {n n₁ nβ‚‚ env env' f body arg val val'} :\n n₁ + nβ‚‚ + 1 ≀ n β†’\n Eval.Indexed n₁ env f (Value.closure env' body) β†’\n Eval.Indexed (n₁ + 1) env arg val β†’\n Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’\n Eval.Indexed n env (Expr.app f arg) val'\n | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} :\n n' < n β†’\n Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval.Indexed n' env arg val β†’\n Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {n env name body} :\n Eval.Indexed n env (Expr.lambda name body) (Value.closure env body)\n | save {n n₁ nβ‚‚ env name value body val val'} :\n n₁ + nβ‚‚ ≀ n β†’\n Eval.Indexed n₁ env value val β†’\n Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’\n Eval.Indexed n env (Expr.save name value body) val'\n | branch_matches {n n' env name args_rev body val} :\n n' < n β†’\n Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {n env name name' args_rev next val} :\n name β‰  name' β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {n n' env name body val} :\n n' < n β†’\n Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval.Indexed n env (Expr.recur name body) val" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "Context", "content": "inductive Context : Type where\n | hole : Context\n | app_left : Context β†’ Expr β†’ Context\n | app_right : Expr β†’ Context β†’ Context\n | constr_app_left : Context β†’ Expr β†’ Context\n | constr_app_right : Expr β†’ Context β†’ Context\n | binop_left : (oper : BinaryOp) β†’ (arg₁ : Context) β†’ (argβ‚‚ : Expr) β†’ Context\n | binop_right : (oper : BinaryOp) β†’ (arg₁ : Expr) β†’ (argβ‚‚ : Context) β†’ Context\n | lambda : (var_name : String) β†’ (body : Context) β†’ Context\n | save_left : (var_name : String) β†’ (value : Context) β†’ (body : Expr) β†’ Context\n | save_right : (var_name : String) β†’ (value : Expr) β†’ (body : Context) β†’ Context\n | branch_left : (constr : Name) β†’ (var_names : List Name) β†’ (body : Context) β†’ (next : Expr) β†’ Context\n | branch_right : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Context) β†’ Context\n | recur : (var_name : Name) β†’ (ctx : Context) β†’ Context\n deriving Inhabited, BEq" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "List.Forallβ‚‚.get", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.Forallβ‚‚.length_eq", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.getElem?_eq_some_iff", "module": "Init.Data.List.Lemmas" }, { "name": "List.get_eq_getElem", "module": "Init.Data.List.Lemmas" }, { "name": "forall_true_left", "module": "Mathlib.Logic.Basic" }, { "name": "and_self", "module": "Init.SimpLemmas" }, { "name": "exists_and_left", "module": "Init.PropLemmas" }, { "name": "exists_const", "module": "Init.PropLemmas" }, { "name": "exists_eq_left'", "module": "Init.PropLemmas" }, { "name": "false_and", "module": "Init.SimpLemmas" }, { "name": "false_or", "module": "Init.SimpLemmas" }, { "name": "implies_true", "module": "Init.SimpLemmas" }, { "name": "or_false", "module": "Init.SimpLemmas" }, { "name": "true_and", "module": "Init.SimpLemmas" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" }, { "name": "Juvix.Core.Main.Expr.Approx.Param.Indexed", "content": "def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Juvix.Core.Main.Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" }, { "name": "Juvix.Core.Main.Expr.Approx.Indexed'", "content": "def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where\n | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit\n | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.Preservation", "content": "def Value.Approx.Indexed.Preservation (k : Nat) : Prop :=\n βˆ€ m n env env' e v,\n m + n < k β†’\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" } ]
[ { "name": "Juvix.Core.Main.Env.Approx.Indexed'.get", "content": "lemma Env.Approx.Indexed'.get {n i : Nat} {env env' o₁}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some o₁) :\n βˆƒ oβ‚‚, env'[i]? = some oβ‚‚ ∧ o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.value", "content": "lemma Env.Approx.Indexed'.value {n i : Nat} {env env' v}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some (Object.value v)) :\n βˆƒ v', env'[i]? = some (Object.value v') ∧ v ≲α΅₯(n) v'" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.delayed", "content": "lemma Env.Approx.Indexed'.delayed {n i : Nat} {env₁ envβ‚‚ env e}\n (h₁ : env₁ ≲ₑ'(n) envβ‚‚)\n (hβ‚‚ : env₁[i]? = some (Object.delayed env e)) :\n (βˆƒ env' e', e ≲(n)⟨env, env'⟩ e' ∧ envβ‚‚[i]? = some (Object.delayed env' e')) ∨\n βˆƒ env', env ≲ₑ'(n) env' ∧ envβ‚‚[i]? = some (Object.delayed env' e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.from_value", "content": "lemma Env.Approx.Indexed'.from_value {n l₁ lβ‚‚} (h : l₁ ≲ₐ(n) lβ‚‚) :\n List.map Object.value l₁ ≲ₑ'(n) List.map Object.value lβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.concat", "content": "lemma Env.Approx.Indexed'.concat {n env₁ envβ‚‚ env₁' envβ‚‚'}\n (h₁ : env₁ ≲ₑ'(n) env₁')\n (hβ‚‚ : envβ‚‚ ≲ₑ'(n) envβ‚‚') :\n env₁ ++ envβ‚‚ ≲ₑ'(n) env₁' ++ envβ‚‚'" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.cons", "content": "lemma Env.Approx.Indexed'.cons {n o₁ oβ‚‚ env₁ envβ‚‚}\n (h₁ : o₁ ≲ₒ'(n) oβ‚‚)\n (hβ‚‚ : env₁ ≲ₑ'(n) envβ‚‚) :\n o₁ :: env₁ ≲ₑ'(n) oβ‚‚ :: envβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.anti_monotone", "content": "lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚" }, { "name": "Juvix.Core.Main.Expr.Approx.Param.Indexed.anti_monotone", "content": "lemma Expr.Approx.Param.Indexed.anti_monotone {n n' env₁ envβ‚‚ e₁ eβ‚‚}\n (h : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲(n')⟨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Juvix.Core.Main.Expr.Approx.Indexed'.anti_monotone", "content": "lemma Expr.Approx.Indexed'.anti_monotone {n n' e₁ eβ‚‚}\n (h : e₁ ≲'(n) eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲'(n') eβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.anti_monotone", "content": " lemma Env.Approx.Indexed'.anti_monotone {n n' env₁ envβ‚‚}\n (h : env₁ ≲ₑ'(n) envβ‚‚)\n (h' : n' ≀ n)\n : env₁ ≲ₑ'(n') envβ‚‚" }, { "name": "Juvix.Core.Main.Object.Approx.Indexed'.anti_monotone", "content": " lemma Object.Approx.Indexed'.anti_monotone {n n' o₁ oβ‚‚} (h : o₁ ≲ₒ'(n) oβ‚‚) (h' : n' ≀ n) : o₁ ≲ₒ'(n') oβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.Preservation.anti_monotone", "content": "lemma Value.Approx.Indexed.Preservation.anti_monotone {k k'} (h : Value.Approx.Indexed.Preservation k) (h' : k' ≀ k) : Value.Approx.Indexed.Preservation k'" } ]
import Juvix.Core.Main.Semantics.Eval import Juvix.Core.Main.Semantics.Eval.Indexed import Juvix.Utils import Mathlib.Tactic.Linarith import Mathlib.Data.List.Forall2 import Aesop namespace Juvix.Core.Main def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop := (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨ (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨ (βˆƒ ctr_name args_rev args_rev', v₁ = Value.constr_app ctr_name args_rev ∧ vβ‚‚ = Value.constr_app ctr_name args_rev' ∧ (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨ (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚, v₁ = Value.closure env₁ body₁ ∧ vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧ (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’ βˆ€ a₁ aβ‚‚ r₁, Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’ a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’ βˆƒ rβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧ Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚)) notation:40 v:40 " ≲α΅₯(" n:40 ") " v':40 => Value.Approx.Indexed n v v' notation:40 args₁:40 " ≲ₐ(" n:40 ") " argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚ def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) notation:40 e:40 " ≲(" n:40 ")⟨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param.Indexed n env env' e e' inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯(n) vβ‚‚ β†’ Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) | delayed_eq {env₁ envβ‚‚ e} : List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e) def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ (Object.Approx.Indexed' n) notation:40 v:40 " ≲ₒ'(" n:40 ") " v':40 => Object.Approx.Indexed' n v v' notation:40 env₁:40 " ≲ₑ'(" n:40 ") " envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚ def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) notation:40 e:40 " ≲'(" n:40 ") " e':40 => Expr.Approx.Indexed' n e e' @[aesop safe cases] inductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c) | constr_app {ctr_name args_rev args_rev'} : (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’ Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev') | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} : (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’ βˆ€ a₁ aβ‚‚ v₁, a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’ a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’ Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚) end def Value.Approx.Indexed.Preservation (k : Nat) : Prop := βˆ€ m n env env' e v, m + n < k β†’ env ≲ₑ'(m + n) env' β†’ env ⊒ e ↦(n) v β†’ βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'
lemma Value.Approx.Indexed.preserved_step {k} : (βˆ€ k' < k, Preservation k') β†’ Preservation k :=
:= by intro ihk intro m n env env' e v hβ‚€ h₁ hβ‚‚ induction hβ‚‚ generalizing m env' case var env i v h => obtain ⟨v', hget, happrox⟩ := Env.Approx.Indexed'.value h₁ h exists v' constructor Β· apply Eval.var aesop Β· apply Value.Approx.Indexed.anti_monotone Β· assumption Β· linarith case var_rec n' env₁ name i env₁' e₁' v' hget heval ih => have hget_or : (βˆƒ envβ‚‚' eβ‚‚', e₁' ≲(m + n')⟨env₁', envβ‚‚'⟩ eβ‚‚' ∧ env'[i]? = some (Object.delayed envβ‚‚' eβ‚‚')) ∨ (βˆƒ envβ‚‚', env₁' ≲ₑ'(m + n') envβ‚‚' ∧ env'[i]? = some (Object.delayed envβ‚‚' e₁')) := by apply Env.Approx.Indexed'.delayed h₁; assumption cases hget_or case inl hget' => obtain ⟨envβ‚‚', eβ‚‚', hβ‚‚, hget'⟩ := hget' simp [Expr.Approx.Param.Indexed] at hβ‚‚ obtain ⟨v'', heval', happrox'⟩ := hβ‚‚ n' m v' (by linarith) heval exists v'' constructor Β· apply Eval.var_rec Β· exact hget' Β· assumption Β· assumption case inr hget' => obtain ⟨envβ‚‚, happrox, hget'⟩ := hget' obtain ⟨v'', heval', happrox'⟩ := ih m envβ‚‚ (by linarith) happrox exists v'' constructor Β· apply Eval.var_rec Β· exact hget' Β· assumption Β· assumption case unit => exists Value.unit constructor Β· apply Eval.unit Β· apply Value.Approx.Indexed.unit case const c => exists Value.const c constructor Β· apply Eval.const Β· apply Value.Approx.Indexed.const case constr ctr_name => exists Value.constr_app ctr_name [] constructor Β· apply Eval.constr Β· apply Value.Approx.Indexed.constr_app intro k hk simp case app n n₁ nβ‚‚ env envβ‚€ f body arg val val' hn hcl hβ‚‚ h₃ ih_f ih_arg ih_body => have : env ≲ₑ'(m + nβ‚‚ + 1 + n₁) env' := by apply Env.Approx.Indexed'.anti_monotone Β· assumption Β· linarith obtain ⟨v_f, heval_f, happrox_f⟩ := ih_f (m + nβ‚‚ + 1) env' (by linarith) this clear this have : env ≲ₑ'(m + nβ‚‚ + n₁ + 1) env' := by apply Env.Approx.Indexed'.anti_monotone Β· assumption Β· linarith obtain ⟨v_arg, heval_arg, happrox_arg⟩ := ih_arg (m + nβ‚‚) env' (by nlinarith) this clear this invert happrox_f case closure cenv cbody ch => have happrox_arg' : val ≲α΅₯(nβ‚‚ + m) v_arg := by have : m + nβ‚‚ = nβ‚‚ + m := by linarith rw [this] at happrox_arg exact happrox_arg obtain ⟨v_body, heval_body, happrox_body⟩ := ch nβ‚‚ m (by linarith) val v_arg val' happrox_arg' h₃ exists v_body constructor Β· apply Eval.app Β· exact heval_f Β· exact heval_arg Β· exact heval_body Β· assumption case constr_app n₁ nβ‚‚ env₁ e₁ cname args arg v' hlt _ hβ‚‚ h₃ hβ‚„ => obtain ⟨v₁, heval_e₁, happrox_eβ‚βŸ© := h₃ m env' (by linarith) h₁ have : env₁ ≲ₑ'(m + nβ‚‚) env' := by apply Env.Approx.Indexed'.anti_monotone Β· assumption Β· linarith obtain ⟨vβ‚‚, heval_arg, happrox_arg⟩ := hβ‚„ m env' (by linarith) this invert happrox_e₁ case constr_app args_rev hargs => exists (Value.constr_app cname (vβ‚‚ :: args_rev)) constructor Β· apply Eval.constr_app Β· exact heval_e₁ Β· exact heval_arg Β· apply Value.Approx.Indexed.constr_app intro k hk constructor Β· apply Value.Approx.Indexed.anti_monotone Β· exact happrox_arg Β· linarith Β· apply hargs linarith case binop n' env₁ op arg₁ argβ‚‚ i₁ iβ‚‚ v₁ vβ‚‚ hv₁ hvβ‚‚ => obtain ⟨v₁', heval₁, happroxβ‚βŸ© := hv₁ m env' (by linarith) h₁ obtain ⟨vβ‚‚', hevalβ‚‚, happroxβ‚‚βŸ© := hvβ‚‚ m env' (by linarith) h₁ invert happrox₁ invert happroxβ‚‚ exists (Value.const (Constant.int (eval_binop_int op i₁ iβ‚‚))) constructor Β· apply Eval.binop Β· exact heval₁ Β· exact hevalβ‚‚ Β· apply Value.Approx.Indexed.const case lambda n' env₁ name body => exists (Value.closure env' body) constructor Β· apply Eval.lambda Β· apply Value.Approx.Indexed.closure intro n₁ nβ‚‚ hlt a₁ aβ‚‚ v₁ happrox heval have happrox_env : a₁ ∷ env₁ ≲ₑ'(n₁ + nβ‚‚) aβ‚‚ ∷ env' := by constructor Β· constructor exact happrox Β· apply Env.Approx.Indexed'.anti_monotone (n := m + n') Β· assumption Β· linarith apply ihk (n₁ + nβ‚‚ + 1) (by linarith) (m := nβ‚‚) (n := n₁) Β· linarith Β· have : n₁ + nβ‚‚ = nβ‚‚ + n₁ := by linarith rw [<- this] exact happrox_env Β· exact heval case save n' n₁ nβ‚‚ env₁ name e₁ eβ‚‚ val val' hle ha₁ haβ‚‚ ih₁ ihβ‚‚ => have : env₁ ≲ₑ'(m + nβ‚‚ + n₁) env' := by apply Env.Approx.Indexed'.anti_monotone Β· assumption Β· linarith obtain ⟨v₁, heval₁, happroxβ‚βŸ© := ih₁ (m + nβ‚‚) env' (by linarith) this clear this have : val ∷ env₁ ≲ₑ'(m + nβ‚‚) v₁ ∷ env' := by constructor Β· apply Object.Approx.Indexed'.value Β· apply Value.Approx.Indexed.anti_monotone Β· exact happrox₁ Β· linarith apply Env.Approx.Indexed'.anti_monotone Β· assumption Β· linarith obtain ⟨vβ‚‚, hevalβ‚‚, happroxβ‚‚βŸ© := ihβ‚‚ m (v₁ ∷ env') (by linarith) this exists vβ‚‚ constructor Β· apply Eval.save Β· exact heval₁ Β· exact hevalβ‚‚ Β· assumption case branch_matches e' n₁ n₁' env₁ name args_rev body val hlt heval_body ih => rcases env' with ⟨⟩ | ⟨⟨hd⟩, env'⟩ case nil => cases h₁ case cons.value => cases h₁ case cons h₁ hβ‚‚ => cases h₁ case value h₁ => invert h₁ case constr_app args_rev' happrox => let args := List.map Object.value args_rev let args' := List.map Object.value args_rev' have : args ++ env₁ ≲ₑ'(m + n₁') args' ++ env' := by apply Env.Approx.Indexed'.concat Β· apply Env.Approx.Indexed'.from_value apply happrox linarith Β· apply Env.Approx.Indexed'.anti_monotone Β· assumption Β· linarith obtain ⟨v', heval', happrox'⟩ := ih m (args' ++ env') (by linarith) this exists v' constructor Β· apply Eval.branch_matches Β· exact heval' Β· assumption case cons.delayed => cases h₁ case cons h _ => cases h case branch_fails e' n' env₁ name name' args eβ‚‚ vβ‚‚ hname heval ih => rcases env' with ⟨⟩ | ⟨⟨hd⟩, env'⟩ case nil => cases h₁ case cons.value => cases h₁ case cons h₁ hβ‚‚ => cases h₁ case value h₁ => invert h₁ case constr_app args_rev h => have h₃ : Value.constr_app name args ∷ env₁ ≲ₑ'(m + n') Value.constr_app name args_rev ∷ env' := by constructor Β· apply Object.Approx.Indexed'.value apply Value.Approx.Indexed.constr_app intro k hk apply h exact hk Β· apply Env.Approx.Indexed'.anti_monotone Β· assumption Β· linarith obtain ⟨v', heval', happrox'⟩ := ih m (Value.constr_app name args_rev ∷ env') (by linarith) h₃ exists v' constructor Β· apply Eval.branch_fails Β· exact hname Β· exact heval' Β· assumption case cons.delayed => cases h₁ case cons h _ => cases h case recur n₁ nβ‚‚ env₁ name body val hn ha₁ ih => let d := Object.delayed env₁ (Expr.recur name body) let d' := Object.delayed env' (Expr.recur name body) have : d ≲ₒ'(m + nβ‚‚) d' := by simp [d, d'] apply Object.Approx.Indexed'.delayed_eq apply Env.Approx.Indexed'.anti_monotone Β· assumption Β· linarith have : d :: env₁ ≲ₑ'(m + nβ‚‚) d' :: env' := by apply Env.Approx.Indexed'.cons Β· assumption Β· apply Env.Approx.Indexed'.anti_monotone Β· assumption Β· linarith obtain ⟨v, heval, happrox⟩ := ih m (d' :: env') (by linarith) this exists v constructor Β· apply Eval.recur exact heval Β· assumption
4
68
true
Semantics
246
Juvix.Core.Main.Value.Approx.Indexed.refl
@[refl] lemma Value.Approx.Indexed.refl {n} v : v ≲α΅₯(n) v
juvix-lean
Juvix/Core/Main/Semantics/Approx/Indexed.lean
[ "import Juvix.Utils", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Mathlib.Tactic.Linarith", "import Mathlib.Data.List.Forall2", "import Juvix.Core.Main.Semantics.Eval", "import Aesop" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.cons", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.nil", "module": "Batteries.Data.List.Basic" }, { "name": "List.cons", "module": "Init.Prelude" }, { "name": "List.nil", "module": "Init.Prelude" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "reduceCtorEq", "module": "Lean.Meta.Tactic.Simp.BuiltinSimprocs.Core" }, { "name": "List.map", "module": "Init.Prelude" } ]
[ { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚\n\nsyntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))\n\nsyntax \"let \" ident \" := \" expr \" in \" expr : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Expr.Approx.Param", "content": "def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)" }, { "name": "Eval.Indexed", "content": "inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where\n | var {n env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval.Indexed n env (Expr.var name idx) val\n | var_rec {n env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval.Indexed n env' expr val β†’\n Eval.Indexed n env (Expr.var name idx) val\n | unit {n env} :\n Eval.Indexed n env Expr.unit Value.unit\n | const {n env c} :\n Eval.Indexed n env (Expr.const c) (Value.const c)\n | constr {n env name} :\n Eval.Indexed n env (Expr.constr name) (Value.constr_app name [])\n | app {n n₁ nβ‚‚ env env' f body arg val val'} :\n n₁ + nβ‚‚ + 1 ≀ n β†’\n Eval.Indexed n₁ env f (Value.closure env' body) β†’\n Eval.Indexed (n₁ + 1) env arg val β†’\n Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’\n Eval.Indexed n env (Expr.app f arg) val'\n | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} :\n n' < n β†’\n Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval.Indexed n' env arg val β†’\n Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {n env name body} :\n Eval.Indexed n env (Expr.lambda name body) (Value.closure env body)\n | save {n n₁ nβ‚‚ env name value body val val'} :\n n₁ + nβ‚‚ ≀ n β†’\n Eval.Indexed n₁ env value val β†’\n Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’\n Eval.Indexed n env (Expr.save name value body) val'\n | branch_matches {n n' env name args_rev body val} :\n n' < n β†’\n Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {n env name name' args_rev next val} :\n name β‰  name' β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {n n' env name body val} :\n n' < n β†’\n Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval.Indexed n env (Expr.recur name body) val" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "Context", "content": "inductive Context : Type where\n | hole : Context\n | app_left : Context β†’ Expr β†’ Context\n | app_right : Expr β†’ Context β†’ Context\n | constr_app_left : Context β†’ Expr β†’ Context\n | constr_app_right : Expr β†’ Context β†’ Context\n | binop_left : (oper : BinaryOp) β†’ (arg₁ : Context) β†’ (argβ‚‚ : Expr) β†’ Context\n | binop_right : (oper : BinaryOp) β†’ (arg₁ : Expr) β†’ (argβ‚‚ : Context) β†’ Context\n | lambda : (var_name : String) β†’ (body : Context) β†’ Context\n | save_left : (var_name : String) β†’ (value : Context) β†’ (body : Expr) β†’ Context\n | save_right : (var_name : String) β†’ (value : Expr) β†’ (body : Context) β†’ Context\n | branch_left : (constr : Name) β†’ (var_names : List Name) β†’ (body : Context) β†’ (next : Expr) β†’ Context\n | branch_right : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Context) β†’ Context\n | recur : (var_name : Name) β†’ (ctx : Context) β†’ Context\n deriving Inhabited, BEq" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "and_self", "module": "Init.SimpLemmas" }, { "name": "exists_and_left", "module": "Init.PropLemmas" }, { "name": "exists_const", "module": "Init.PropLemmas" }, { "name": "exists_eq_left'", "module": "Init.PropLemmas" }, { "name": "false_and", "module": "Init.SimpLemmas" }, { "name": "false_or", "module": "Init.SimpLemmas" }, { "name": "implies_true", "module": "Init.SimpLemmas" }, { "name": "or_false", "module": "Init.SimpLemmas" }, { "name": "true_and", "module": "Init.SimpLemmas" }, { "name": "List.forallβ‚‚_same", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.Forallβ‚‚.get", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.Forallβ‚‚.length_eq", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.getElem?_eq_some_iff", "module": "Init.Data.List.Lemmas" }, { "name": "List.get_eq_getElem", "module": "Init.Data.List.Lemmas" }, { "name": "forall_true_left", "module": "Mathlib.Logic.Basic" }, { "name": "Nat.le_eq", "module": "Init.Data.Nat.Basic" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" }, { "name": "Juvix.Core.Main.Expr.Approx.Param.Indexed", "content": "def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Juvix.Core.Main.Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" }, { "name": "Juvix.Core.Main.Expr.Approx.Indexed'", "content": "def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where\n | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit\n | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.Preservation", "content": "def Value.Approx.Indexed.Preservation (k : Nat) : Prop :=\n βˆ€ m n env env' e v,\n m + n < k β†’\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" } ]
[ { "name": "Juvix.Core.Main.Env.Approx.Indexed'.get", "content": "lemma Env.Approx.Indexed'.get {n i : Nat} {env env' o₁}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some o₁) :\n βˆƒ oβ‚‚, env'[i]? = some oβ‚‚ ∧ o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.value", "content": "lemma Env.Approx.Indexed'.value {n i : Nat} {env env' v}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some (Object.value v)) :\n βˆƒ v', env'[i]? = some (Object.value v') ∧ v ≲α΅₯(n) v'" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.delayed", "content": "lemma Env.Approx.Indexed'.delayed {n i : Nat} {env₁ envβ‚‚ env e}\n (h₁ : env₁ ≲ₑ'(n) envβ‚‚)\n (hβ‚‚ : env₁[i]? = some (Object.delayed env e)) :\n (βˆƒ env' e', e ≲(n)⟨env, env'⟩ e' ∧ envβ‚‚[i]? = some (Object.delayed env' e')) ∨\n βˆƒ env', env ≲ₑ'(n) env' ∧ envβ‚‚[i]? = some (Object.delayed env' e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.from_value", "content": "lemma Env.Approx.Indexed'.from_value {n l₁ lβ‚‚} (h : l₁ ≲ₐ(n) lβ‚‚) :\n List.map Object.value l₁ ≲ₑ'(n) List.map Object.value lβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.concat", "content": "lemma Env.Approx.Indexed'.concat {n env₁ envβ‚‚ env₁' envβ‚‚'}\n (h₁ : env₁ ≲ₑ'(n) env₁')\n (hβ‚‚ : envβ‚‚ ≲ₑ'(n) envβ‚‚') :\n env₁ ++ envβ‚‚ ≲ₑ'(n) env₁' ++ envβ‚‚'" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.cons", "content": "lemma Env.Approx.Indexed'.cons {n o₁ oβ‚‚ env₁ envβ‚‚}\n (h₁ : o₁ ≲ₒ'(n) oβ‚‚)\n (hβ‚‚ : env₁ ≲ₑ'(n) envβ‚‚) :\n o₁ :: env₁ ≲ₑ'(n) oβ‚‚ :: envβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.anti_monotone", "content": "lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚" }, { "name": "Juvix.Core.Main.Expr.Approx.Param.Indexed.anti_monotone", "content": "lemma Expr.Approx.Param.Indexed.anti_monotone {n n' env₁ envβ‚‚ e₁ eβ‚‚}\n (h : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲(n')⟨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Juvix.Core.Main.Expr.Approx.Indexed'.anti_monotone", "content": "lemma Expr.Approx.Indexed'.anti_monotone {n n' e₁ eβ‚‚}\n (h : e₁ ≲'(n) eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲'(n') eβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.anti_monotone", "content": " lemma Env.Approx.Indexed'.anti_monotone {n n' env₁ envβ‚‚}\n (h : env₁ ≲ₑ'(n) envβ‚‚)\n (h' : n' ≀ n)\n : env₁ ≲ₑ'(n') envβ‚‚" }, { "name": "Juvix.Core.Main.Object.Approx.Indexed'.anti_monotone", "content": " lemma Object.Approx.Indexed'.anti_monotone {n n' o₁ oβ‚‚} (h : o₁ ≲ₒ'(n) oβ‚‚) (h' : n' ≀ n) : o₁ ≲ₒ'(n') oβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.Preservation.anti_monotone", "content": "lemma Value.Approx.Indexed.Preservation.anti_monotone {k k'} (h : Value.Approx.Indexed.Preservation k) (h' : k' ≀ k) : Value.Approx.Indexed.Preservation k'" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.preserved_step", "content": "lemma Value.Approx.Indexed.preserved_step {k} :\n (βˆ€ k' < k, Preservation k') β†’ Preservation k" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.preserved'", "content": "lemma Value.Approx.Indexed.preserved' {k} : Preservation k" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.preserved", "content": "theorem Value.Approx.Indexed.preserved :\n βˆ€ m n env env' e v,\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.refl'", "content": " lemma Env.Approx.Indexed'.refl' {n env} (h : βˆ€ v, v ≲α΅₯(n) v) : env ≲ₑ'(n) env" }, { "name": "Juvix.Core.Main.Object.Approx.Indexed'.refl'", "content": " lemma Object.Approx.Indexed'.refl' {n o} (h : βˆ€ v, v ≲α΅₯(n) v) : o ≲ₒ'(n) o" } ]
import Juvix.Core.Main.Semantics.Eval import Juvix.Core.Main.Semantics.Eval.Indexed import Juvix.Utils import Mathlib.Tactic.Linarith import Mathlib.Data.List.Forall2 import Aesop namespace Juvix.Core.Main def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop := (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨ (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨ (βˆƒ ctr_name args_rev args_rev', v₁ = Value.constr_app ctr_name args_rev ∧ vβ‚‚ = Value.constr_app ctr_name args_rev' ∧ (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨ (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚, v₁ = Value.closure env₁ body₁ ∧ vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧ (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’ βˆ€ a₁ aβ‚‚ r₁, Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’ a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’ βˆƒ rβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧ Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚)) notation:40 v:40 " ≲α΅₯(" n:40 ") " v':40 => Value.Approx.Indexed n v v' notation:40 args₁:40 " ≲ₐ(" n:40 ") " argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚ def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) notation:40 e:40 " ≲(" n:40 ")⟨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param.Indexed n env env' e e' inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯(n) vβ‚‚ β†’ Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) | delayed_eq {env₁ envβ‚‚ e} : List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e) def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ (Object.Approx.Indexed' n) notation:40 v:40 " ≲ₒ'(" n:40 ") " v':40 => Object.Approx.Indexed' n v v' notation:40 env₁:40 " ≲ₑ'(" n:40 ") " envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚ def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) notation:40 e:40 " ≲'(" n:40 ") " e':40 => Expr.Approx.Indexed' n e e' @[aesop safe cases] inductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c) | constr_app {ctr_name args_rev args_rev'} : (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’ Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev') | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} : (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’ βˆ€ a₁ aβ‚‚ v₁, a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’ a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’ Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚) end def Value.Approx.Indexed.Preservation (k : Nat) : Prop := βˆ€ m n env env' e v, m + n < k β†’ env ≲ₑ'(m + n) env' β†’ env ⊒ e ↦(n) v β†’ βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v' end
@[refl] lemma Value.Approx.Indexed.refl {n} v : v ≲α΅₯(n) v :=
:= by revert n suffices βˆ€ n, βˆ€ k ≀ n, v ≲α΅₯(k) v by intro k exact this k k k.le_refl intro n induction n generalizing v with | zero => intros k hk cases v case unit => exact Value.Approx.Indexed.unit case const c => exact Value.Approx.Indexed.const case constr_app ctr_name args_rev => apply Value.Approx.Indexed.constr_app Β· intros have : k = 0 := by linarith subst k contradiction case closure env body => apply Value.Approx.Indexed.closure Β· intros have : k = 0 := by linarith subst k contradiction | succ n ih => intros k hk cases v case unit => exact Value.Approx.Indexed.unit case const c => exact Value.Approx.Indexed.const case constr_app ctr_name args_rev => apply Value.Approx.Indexed.constr_app Β· intros k' hk' have : k' ≀ n := by linarith rw [List.forallβ‚‚_same] intros apply ih Β· assumption case closure env body => apply Value.Approx.Indexed.closure Β· intros n₁ nβ‚‚ hn a₁ aβ‚‚ r₁ happrox heval have henv : a₁ ∷ env ≲ₑ'(n₁ + nβ‚‚) aβ‚‚ ∷ env := by simp [Env.Approx.Indexed'] constructor Β· constructor; exact happrox Β· intro x _ cases x case value v₁ vβ‚‚ => apply Object.Approx.Indexed'.value Β· apply ih Β· linarith case delayed => apply Object.Approx.Indexed'.refl' intro v apply ih linarith apply Value.Approx.Indexed.preserved (n := n₁) (m := nβ‚‚) Β· have : n₁ + nβ‚‚ = nβ‚‚ + n₁ := by linarith rw [<- this] exact henv Β· assumption
7
80
true
Semantics
247
Juvix.Core.Main.Eval.toIndexed
lemma Eval.toIndexed {env e v} (h : env ⊒ e ↦ v) : βˆƒ n, env ⊒ e ↦(n) v
juvix-lean
Juvix/Core/Main/Semantics/Eval/Indexed.lean
[ "import Mathlib.Tactic.Linarith", "import Juvix.Core.Main.Semantics.Eval" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" } ]
[ { "name": "syntax:100 expr:100 ppSpace expr:101 : expr", "content": "syntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Context", "content": "inductive Context : Type where\n | hole : Context\n | app_left : Context β†’ Expr β†’ Context\n | app_right : Expr β†’ Context β†’ Context\n | constr_app_left : Context β†’ Expr β†’ Context\n | constr_app_right : Expr β†’ Context β†’ Context\n | binop_left : (oper : BinaryOp) β†’ (arg₁ : Context) β†’ (argβ‚‚ : Expr) β†’ Context\n | binop_right : (oper : BinaryOp) β†’ (arg₁ : Expr) β†’ (argβ‚‚ : Context) β†’ Context\n | lambda : (var_name : String) β†’ (body : Context) β†’ Context\n | save_left : (var_name : String) β†’ (value : Context) β†’ (body : Expr) β†’ Context\n | save_right : (var_name : String) β†’ (value : Expr) β†’ (body : Context) β†’ Context\n | branch_left : (constr : Name) β†’ (var_names : List Name) β†’ (body : Context) β†’ (next : Expr) β†’ Context\n | branch_right : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Context) β†’ Context\n | recur : (var_name : Name) β†’ (ctx : Context) β†’ Context\n deriving Inhabited, BEq" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Termination.var", "content": "lemma Termination.var {env name i v} :\n env[i]? = some (Object.value v) β†’\n env ⊒ Expr.var name i ↓" }, { "name": "Termination.var_rec", "content": "lemma Termination.var_rec {env name i env' e} :\n env[i]? = some (Object.delayed env' e) β†’\n env' ⊒ e ↓ β†’\n env ⊒ (Expr.var name i) ↓" }, { "name": "Termination.unit", "content": "lemma Termination.unit {env} :\n env ⊒ Expr.unit ↓" }, { "name": "Termination.const", "content": "lemma Termination.const {env c} :\n env ⊒ Expr.const c ↓" }, { "name": "Termination.constr", "content": "lemma Termination.constr {env nm} :\n env ⊒ Expr.constr nm ↓" }, { "name": "Termination.app", "content": "lemma Termination.app {env e₁ eβ‚‚ v env' body} :\n env ⊒ e₁ ↦ Value.closure env' body β†’\n env ⊒ eβ‚‚ ↦ v β†’\n v ∷ env' ⊒ body ↓ β†’\n env ⊒ Expr.app e₁ eβ‚‚ ↓" }, { "name": "Termination.constr_app", "content": "lemma Termination.constr_app {env e₁ eβ‚‚ e₁₁ e₁₂} :\n env ⊒ e₁ ↦ Value.constr_app e₁₁ e₁₂ β†’\n env ⊒ eβ‚‚ ↓ β†’\n env ⊒ Expr.constr_app e₁ eβ‚‚ ↓" }, { "name": "Termination.binop", "content": "lemma Termination.binop {env op e₁ eβ‚‚ c₁ cβ‚‚} :\n env ⊒ e₁ ↦ Value.const (Constant.int c₁) β†’\n env ⊒ eβ‚‚ ↦ Value.const (Constant.int cβ‚‚) β†’\n env ⊒ Expr.binop op e₁ eβ‚‚ ↓" }, { "name": "Termination.lambda", "content": "lemma Termination.lambda {env name e} : env ⊒ Expr.lambda name e ↓" }, { "name": "Termination.save", "content": "lemma Termination.save {env name e₁ eβ‚‚ v} :\n env ⊒ e₁ ↦ v β†’\n v ∷ env ⊒ eβ‚‚ ↓ β†’\n env ⊒ Expr.save name e₁ eβ‚‚ ↓" }, { "name": "Termination.branch_matches", "content": "lemma Termination.branch_matches {env name vnames args_rev e e'} :\n args_rev.map Object.value ++ env ⊒ e ↓ β†’\n Value.constr_app name args_rev ∷ env ⊒ Expr.branch name vnames e e' ↓" }, { "name": "Termination.branch_fails", "content": "lemma Termination.branch_fails {env name name' vnames args_rev e e'} :\n name β‰  name' β†’\n Value.constr_app name args_rev ∷ env ⊒ e' ↓ β†’\n Value.constr_app name args_rev ∷ env ⊒ Expr.branch name' vnames e e' ↓" }, { "name": "Termination.recur", "content": "lemma Termination.recur {env name e} :\n Object.delayed env (Expr.recur name e) :: env ⊒ e ↓ β†’\n env ⊒ Expr.recur name e ↓" } ]
[ { "name": "Juvix.Core.Main.Eval.Indexed", "content": "inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where\n | var {n env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval.Indexed n env (Expr.var name idx) val\n | var_rec {n env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval.Indexed n env' expr val β†’\n Eval.Indexed n env (Expr.var name idx) val\n | unit {n env} :\n Eval.Indexed n env Expr.unit Value.unit\n | const {n env c} :\n Eval.Indexed n env (Expr.const c) (Value.const c)\n | constr {n env name} :\n Eval.Indexed n env (Expr.constr name) (Value.constr_app name [])\n | app {n n₁ nβ‚‚ env env' f body arg val val'} :\n n₁ + nβ‚‚ + 1 ≀ n β†’\n Eval.Indexed n₁ env f (Value.closure env' body) β†’\n Eval.Indexed (n₁ + 1) env arg val β†’\n Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’\n Eval.Indexed n env (Expr.app f arg) val'\n | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} :\n n' < n β†’\n Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval.Indexed n' env arg val β†’\n Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {n env name body} :\n Eval.Indexed n env (Expr.lambda name body) (Value.closure env body)\n | save {n n₁ nβ‚‚ env name value body val val'} :\n n₁ + nβ‚‚ ≀ n β†’\n Eval.Indexed n₁ env value val β†’\n Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’\n Eval.Indexed n env (Expr.save name value body) val'\n | branch_matches {n n' env name args_rev body val} :\n n' < n β†’\n Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {n env name name' args_rev next val} :\n name β‰  name' β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {n n' env name body val} :\n n' < n β†’\n Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval.Indexed n env (Expr.recur name body) val" } ]
[ { "name": "Juvix.Core.Main.Eval.Indexed.monotone", "content": "lemma Eval.Indexed.monotone {n n' env e v} (h : env ⊒ e ↦(n) v) (h' : n ≀ n') : env ⊒ e ↦(n') v" } ]
import Juvix.Core.Main.Semantics.Eval import Mathlib.Tactic.Linarith namespace Juvix.Core.Main inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where | var {n env name idx val} : env[idx]? = some (Object.value val) β†’ Eval.Indexed n env (Expr.var name idx) val | var_rec {n env name idx env' expr val} : env[idx]? = some (Object.delayed env' expr) β†’ Eval.Indexed n env' expr val β†’ Eval.Indexed n env (Expr.var name idx) val | unit {n env} : Eval.Indexed n env Expr.unit Value.unit | const {n env c} : Eval.Indexed n env (Expr.const c) (Value.const c) | constr {n env name} : Eval.Indexed n env (Expr.constr name) (Value.constr_app name []) | app {n n₁ nβ‚‚ env env' f body arg val val'} : n₁ + nβ‚‚ + 1 ≀ n β†’ Eval.Indexed n₁ env f (Value.closure env' body) β†’ Eval.Indexed (n₁ + 1) env arg val β†’ Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’ Eval.Indexed n env (Expr.app f arg) val' | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} : n' < n β†’ Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’ Eval.Indexed n' env arg val β†’ Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev)) | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} : Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’ Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’ Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚))) | lambda {n env name body} : Eval.Indexed n env (Expr.lambda name body) (Value.closure env body) | save {n n₁ nβ‚‚ env name value body val val'} : n₁ + nβ‚‚ ≀ n β†’ Eval.Indexed n₁ env value val β†’ Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’ Eval.Indexed n env (Expr.save name value body) val' | branch_matches {n n' env name args_rev body val} : n' < n β†’ Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’ Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val | branch_fails {n env name name' args_rev next val} : name β‰  name' β†’ Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’ Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val | recur {n n' env name body val} : n' < n β†’ Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’ Eval.Indexed n env (Expr.recur name body) val notation:40 env:40 " ⊒ " e:40 " ↦(" n ") " v:40 => Eval.Indexed n env e v
lemma Eval.toIndexed {env e v} (h : env ⊒ e ↦ v) : βˆƒ n, env ⊒ e ↦(n) v :=
:= by induction h case var => exists 0; apply Eval.Indexed.var; assumption case var_rec ih => obtain ⟨n, ih⟩ := ih exists n apply Eval.Indexed.var_rec <;> assumption case unit => exists 0; apply Eval.Indexed.unit case const => exists 0; apply Eval.Indexed.const case constr => exists 0; apply Eval.Indexed.constr case app env env' f body arg val val' _ _ _ ih1 ih2 ih3 => obtain ⟨n₁, ihβ‚βŸ© := ih1 obtain ⟨nβ‚‚, ihβ‚‚βŸ© := ih2 obtain ⟨n₃, ihβ‚ƒβŸ© := ih3 have ih₁' : env ⊒ f ↦(n₁ + nβ‚‚) Value.closure env' body := by apply Eval.Indexed.monotone ih₁; linarith have ihβ‚‚' : env ⊒ arg ↦(n₁ + nβ‚‚ + 1) val := by apply Eval.Indexed.monotone ihβ‚‚; linarith exists (n₁ + nβ‚‚ + n₃ + 1) apply Eval.Indexed.app Β· rfl Β· exact ih₁' Β· exact ihβ‚‚' Β· exact ih₃ case constr_app ih₁ ihβ‚‚ => obtain ⟨n₁, ihβ‚βŸ© := ih₁ obtain ⟨nβ‚‚, ihβ‚‚βŸ© := ihβ‚‚ exists (n₁ + nβ‚‚ + 1) apply Eval.Indexed.constr_app (n' := n₁ + nβ‚‚) Β· linarith Β· apply Eval.Indexed.monotone ih₁; linarith Β· apply Eval.Indexed.monotone ihβ‚‚; linarith case binop ih₁ ihβ‚‚ => obtain ⟨n₁, ihβ‚βŸ© := ih₁ obtain ⟨nβ‚‚, ihβ‚‚βŸ© := ihβ‚‚ exists (n₁ + nβ‚‚) apply Eval.Indexed.binop (n := n₁ + nβ‚‚) Β· apply Eval.Indexed.monotone ih₁; linarith Β· apply Eval.Indexed.monotone ihβ‚‚; linarith case lambda => exists 0; apply Eval.Indexed.lambda case save ih₁ ihβ‚‚ => obtain ⟨n₁, ihβ‚βŸ© := ih₁ obtain ⟨nβ‚‚, ihβ‚‚βŸ© := ihβ‚‚ exists (n₁ + nβ‚‚) apply Eval.Indexed.save (n := n₁ + nβ‚‚) Β· rfl Β· apply Eval.Indexed.monotone ih₁; linarith Β· apply Eval.Indexed.monotone ihβ‚‚; linarith case branch_matches ih => obtain ⟨n, ih⟩ := ih exists (n + 1) apply Eval.Indexed.branch_matches (n' := n) Β· linarith Β· assumption case branch_fails ih => obtain ⟨n, ih⟩ := ih exists n apply Eval.Indexed.branch_fails <;> assumption case recur ih => obtain ⟨n, ih⟩ := ih exists n.succ apply Eval.Indexed.recur (n' := n) Β· linarith Β· assumption
3
24
true
Semantics
248
Juvix.Core.Main.Termination.recur
lemma Termination.recur {env name e} : Object.delayed env (Expr.recur name e) :: env ⊒ e ↓ β†’ env ⊒ Expr.recur name e ↓
juvix-lean
Juvix/Core/Main/Tactics/Termination.lean
[ "import Juvix.Core.Main.Tactics.Base" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" } ]
[ { "name": "syntax:100 expr:100 ppSpace expr:101 : expr", "content": "syntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Eval.Defined", "content": "def Eval.Defined (env : Env) (e : Expr) : Prop :=\n βˆƒ v, env ⊒ e ↦ v" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[]
import Juvix.Core.Main.Tactics.Base namespace Juvix.Core.Main
lemma Termination.recur {env name e} : Object.delayed env (Expr.recur name e) :: env ⊒ e ↓ β†’ env ⊒ Expr.recur name e ↓ :=
:= by unfold Eval.Defined intro h obtain ⟨w, h⟩ := h exists w · apply Juvix.Core.Main.Eval.recur exact h
4
19
false
Semantics
249
Juvix.Core.Main.Value.Approx.Indexed.trans
@[trans] lemma Value.Approx.Indexed.trans {n v₁ vβ‚‚ v₃} : v₁ ≲α΅₯(n) vβ‚‚ β†’ vβ‚‚ ≲α΅₯ v₃ β†’ v₁ ≲α΅₯(n) v₃
juvix-lean
Juvix/Core/Main/Semantics/Approx.lean
[ "import Juvix.Core.Main.Semantics.Approx.Indexed", "import Juvix.Utils" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "IsEmpty", "module": "Mathlib.Logic.IsEmpty" } ]
[ { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.A", "content": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Value.Approx.Indexed.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where\n | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit\n | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "IsEmpty.forall_iff", "module": "Mathlib.Logic.IsEmpty" }, { "name": "implies_true", "module": "Init.SimpLemmas" }, { "name": "nonpos_iff_eq_zero", "module": "Mathlib.Algebra.Order.Monoid.Canonical.Defs" }, { "name": "not_lt_zero'", "module": "Mathlib.Algebra.Order.GroupWithZero.Canonical" } ]
[ { "name": "Value.Approx.Indexed.invert", "content": "@[aesop unsafe destruct]\nlemma Value.Approx.Indexed.invert {n v v'} :\n v ≲α΅₯(n) v' β†’\n Value.Approx.Indexed.Inversion n v v'" }, { "name": "Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "forallβ‚‚_trans'", "content": "theorem forallβ‚‚_trans' {Ξ±} {P Q R : Ξ± β†’ Ξ± β†’ Prop} {l₁ lβ‚‚ l₃}\n (h : βˆ€ x y z, P x y β†’ Q y z β†’ R x z)\n (h₁ : List.Forallβ‚‚ P l₁ lβ‚‚)\n (hβ‚‚ : List.Forallβ‚‚ Q lβ‚‚ l₃)\n : List.Forallβ‚‚ R l₁ l₃" } ]
[ { "name": "Juvix.Core.Main.Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Juvix.Core.Main.Value.Approx.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Inversion : Value -> Value -> Prop where\n | unit : Value.Approx.Inversion Value.unit Value.unit\n | const {c} : Value.Approx.Inversion (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n args_rev ≲ₐ args_rev' β†’\n Value.Approx.Inversion (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’\n Value.Approx.Inversion (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.invert", "content": "@[aesop unsafe destruct]\nlemma Value.Approx.invert {v v'} :\n v ≲α΅₯ v' β†’\n Value.Approx.Inversion v v'" } ]
import Juvix.Core.Main.Semantics.Approx.Indexed namespace Juvix.Core.Main def Value.Approx (v v' : Value) : Prop := βˆ€ n, v ≲α΅₯(n) v' notation:40 v:40 " ≲α΅₯ " v':40 => Value.Approx v v' notation:40 args₁:40 " ≲ₐ " argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚ notation:40 e:40 " β‰²βŸ¨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param env env' e e' notation:40 v:40 " ≲ₒ " v':40 => Object.Approx v v' notation:40 env₁:40 " ≲ₑ " envβ‚‚:40 => Env.Approx env₁ envβ‚‚ notation:40 e₁:40 " ≲ " eβ‚‚:40 => Expr.Approx e₁ eβ‚‚ @[aesop safe cases] inductive Value.Approx.Inversion : Value -> Value -> Prop where | unit : Value.Approx.Inversion Value.unit Value.unit | const {c} : Value.Approx.Inversion (Value.const c) (Value.const c) | constr_app {ctr_name args_rev args_rev'} : args_rev ≲ₐ args_rev' β†’ Value.Approx.Inversion (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev') | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} : (βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’ Value.Approx.Inversion (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)
@[trans] lemma Value.Approx.Indexed.trans {n v₁ vβ‚‚ v₃} : v₁ ≲α΅₯(n) vβ‚‚ β†’ vβ‚‚ ≲α΅₯ v₃ β†’ v₁ ≲α΅₯(n) v₃ :=
:= by revert n suffices βˆ€ n, βˆ€ k ≀ n, v₁ ≲α΅₯(k) vβ‚‚ β†’ vβ‚‚ ≲α΅₯ v₃ β†’ v₁ ≲α΅₯(k) v₃ by intro k exact this k k k.le_refl intros n induction n generalizing v₁ vβ‚‚ v₃ with | zero => intros k hk h₁ hβ‚‚ invert h₁ case unit => invert hβ‚‚ case unit => exact Value.Approx.Indexed.unit case const => invert hβ‚‚ case const => exact Value.Approx.Indexed.const case constr_app ctr_name args_rev₁ args_rev₁' ch₁ => cases hβ‚‚.invert case constr_app args_revβ‚‚ chβ‚‚ => apply Value.Approx.Indexed.constr_app; intros simp_all only [nonpos_iff_eq_zero, not_lt_zero', IsEmpty.forall_iff, implies_true] case closure env₁ body₁ env₁' body₁' ch₁ => cases hβ‚‚.invert case closure envβ‚‚ bodyβ‚‚ chβ‚‚ => apply Value.Approx.Indexed.closure Β· intro k' hk' v v₁ h have : k = 0 := by linarith subst k contradiction | succ n ih => intros k hk h₁ hβ‚‚ invert h₁ case unit => invert hβ‚‚ case unit => exact Value.Approx.Indexed.unit case const => invert hβ‚‚ case const => exact Value.Approx.Indexed.const case constr_app ctr_name args_rev args_rev' ch₁ => invert hβ‚‚ case constr_app args_rev'' chβ‚‚ => apply Value.Approx.Indexed.constr_app Β· intro k' hk' have hk' : k' ≀ n := by linarith apply Utils.forallβ‚‚_trans' (P := fun v₁ vβ‚‚ => v₁ ≲α΅₯(k') vβ‚‚) (Q := fun v₁ vβ‚‚ => v₁ ≲α΅₯ vβ‚‚) Β· intros v₁ vβ‚‚ v₃ h₁ hβ‚‚ apply ih <;> assumption Β· apply ch₁ simp_all only Β· apply chβ‚‚ case closure env₁ body₁ envβ‚‚ bodyβ‚‚ ch₁ => invert hβ‚‚ case closure env₃ body₃ chβ‚‚ => apply Value.Approx.Indexed.closure Β· intro n₁ nβ‚‚ hn a₁ a₃ v₁ happrox heval₁ have ah₁ : βˆƒ vβ‚‚, (a₃ ∷ envβ‚‚) ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚ := by apply ch₁ Β· assumption Β· assumption Β· assumption obtain ⟨vβ‚‚, hevalβ‚‚, hβ‚‚βŸ© := ah₁ have ahβ‚‚ : βˆƒ v₃, (a₃ ∷ env₃) ⊒ body₃ ↦ v₃ ∧ vβ‚‚ ≲α΅₯ v₃ := by apply chβ‚‚ Β· rfl Β· assumption obtain ⟨v₃, _, hβ‚ƒβŸ© := ahβ‚‚ have : nβ‚‚ ≀ n := by linarith exists v₃ aesop
3
33
true
Semantics
250
Juvix.Core.Main.Value.Approx.Indexed.anti_monotone
lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚
juvix-lean
Juvix/Core/Main/Semantics/Approx/Indexed.lean
[ "import Juvix.Utils", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Mathlib.Tactic.Linarith", "import Mathlib.Data.List.Forall2", "import Juvix.Core.Main.Semantics.Eval", "import Aesop" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "reduceCtorEq", "module": "Lean.Meta.Tactic.Simp.BuiltinSimprocs.Core" } ]
[ { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "and_self", "module": "Init.SimpLemmas" }, { "name": "exists_and_left", "module": "Init.PropLemmas" }, { "name": "exists_const", "module": "Init.PropLemmas" }, { "name": "exists_eq_left'", "module": "Init.PropLemmas" }, { "name": "false_and", "module": "Init.SimpLemmas" }, { "name": "false_or", "module": "Init.SimpLemmas" }, { "name": "implies_true", "module": "Init.SimpLemmas" }, { "name": "or_false", "module": "Init.SimpLemmas" }, { "name": "true_and", "module": "Init.SimpLemmas" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" } ]
import Juvix.Core.Main.Semantics.Eval import Juvix.Core.Main.Semantics.Eval.Indexed import Juvix.Utils import Mathlib.Tactic.Linarith import Mathlib.Data.List.Forall2 import Aesop namespace Juvix.Core.Main def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop := (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨ (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨ (βˆƒ ctr_name args_rev args_rev', v₁ = Value.constr_app ctr_name args_rev ∧ vβ‚‚ = Value.constr_app ctr_name args_rev' ∧ (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨ (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚, v₁ = Value.closure env₁ body₁ ∧ vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧ (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’ βˆ€ a₁ aβ‚‚ r₁, Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’ a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’ βˆƒ rβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧ Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚)) notation:40 v:40 " ≲α΅₯(" n:40 ") " v':40 => Value.Approx.Indexed n v v' notation:40 args₁:40 " ≲ₐ(" n:40 ") " argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚ notation:40 e:40 " ≲(" n:40 ")⟨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param.Indexed n env env' e e' notation:40 v:40 " ≲ₒ'(" n:40 ") " v':40 => Object.Approx.Indexed' n v v' notation:40 env₁:40 " ≲ₑ'(" n:40 ") " envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚ notation:40 e:40 " ≲'(" n:40 ") " e':40 => Expr.Approx.Indexed' n e e'
lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚ :=
:= by revert n n' suffices βˆ€ n, v₁ ≲α΅₯(n) vβ‚‚ β†’ βˆ€ k ≀ n, v₁ ≲α΅₯(k) vβ‚‚ by intro n n' h hn exact this n h n' hn intro n induction n generalizing v₁ vβ‚‚ with | zero => intros h k hk invert h case unit => exact Value.Approx.Indexed.unit case const => exact Value.Approx.Indexed.const case constr_app ctr_name args_rev args_rev' hargs => apply Value.Approx.Indexed.constr_app Β· intros have : k = 0 := by linarith subst k contradiction case closure env₁ body₁ envβ‚‚ bodyβ‚‚ h => apply Value.Approx.Indexed.closure Β· intros have : k = 0 := by linarith subst k contradiction | succ n ih => intros h k hk invert h case unit => exact Value.Approx.Indexed.unit case const => exact Value.Approx.Indexed.const case constr_app ctr_name args_rev args_rev' hargs => apply Value.Approx.Indexed.constr_app Β· intros k' hk' have : k' < n + 1 := by linarith simp_all only case closure env₁ body₁ envβ‚‚ bodyβ‚‚ ch => apply Value.Approx.Indexed.closure Β· intro n₁ nβ‚‚ hn a₁ aβ‚‚ v₁ happrox heval apply ch n₁ nβ‚‚ Β· linarith Β· assumption Β· assumption
3
34
true
Semantics
251
Juvix.Core.Main.Expr.Approx.Context.preserved
lemma Expr.Approx.Context.preserved (e₁ eβ‚‚ : Expr) : e₁ ≲ eβ‚‚ β†’ βˆ€ (C : Context) env₁ envβ‚‚ v₁, env₁ ≲ₑ envβ‚‚ β†’ env₁ ⊒ C.subst e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ C.subst eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚
juvix-lean
Juvix/Core/Main/Semantics/Approx/Soundness.lean
[ "import Juvix.Core.Main.Semantics.Approx.Indexed", "import Juvix.Core.Main.Semantics.Approx", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Juvix.Core.Main.Semantics.Approx.Contextual", "import Juvix.Core.Main.Semantics.Eval" ]
[ { "name": "List", "module": "Init.Prelude" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.map", "module": "Init.Prelude" } ]
[ { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'\n\nsyntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr" }, { "name": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.A", "content": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚\n\nsyntax \"let \" ident \" := \" expr \" in \" expr : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)" }, { "name": "Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Context.subst", "content": "@[simp]\ndef Context.subst (C : Context) (e : Expr) : Expr :=\n match C with\n | Context.hole => e\n | Context.app_left C' e' => Expr.app (C'.subst e) e'\n | Context.app_right e' C' => Expr.app e' (C'.subst e)\n | Context.constr_app_left C' e' => Expr.constr_app (C'.subst e) e'\n | Context.constr_app_right e' C' => Expr.constr_app e' (C'.subst e)\n | Context.binop_left oper C₁ eβ‚‚ => Expr.binop oper (C₁.subst e) eβ‚‚\n | Context.binop_right oper e₁ Cβ‚‚ => Expr.binop oper e₁ (Cβ‚‚.subst e)\n | Context.lambda s C' => Expr.lambda s (C'.subst e)\n | Context.save_left s C' e' => Expr.save s (C'.subst e) e'\n | Context.save_right s e' C' => Expr.save s e' (C'.subst e)\n | Context.branch_left constr names C' next => Expr.branch constr names (C'.subst e) next\n | Context.branch_right constr names body C' => Expr.branch constr names body (C'.subst e)\n | Context.recur name C' => Expr.recur name (C'.subst e)" }, { "name": "Context", "content": "inductive Context : Type where\n | hole : Context\n | app_left : Context β†’ Expr β†’ Context\n | app_right : Expr β†’ Context β†’ Context\n | constr_app_left : Context β†’ Expr β†’ Context\n | constr_app_right : Expr β†’ Context β†’ Context\n | binop_left : (oper : BinaryOp) β†’ (arg₁ : Context) β†’ (argβ‚‚ : Expr) β†’ Context\n | binop_right : (oper : BinaryOp) β†’ (arg₁ : Expr) β†’ (argβ‚‚ : Context) β†’ Context\n | lambda : (var_name : String) β†’ (body : Context) β†’ Context\n | save_left : (var_name : String) β†’ (value : Context) β†’ (body : Expr) β†’ Context\n | save_right : (var_name : String) β†’ (value : Expr) β†’ (body : Context) β†’ Context\n | branch_left : (constr : Name) β†’ (var_names : List Name) β†’ (body : Context) β†’ (next : Expr) β†’ Context\n | branch_right : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Context) β†’ Context\n | recur : (var_name : Name) β†’ (ctx : Context) β†’ Context\n deriving Inhabited, BEq" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Value.Approx.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Inversion : Value -> Value -> Prop where\n | unit : Value.Approx.Inversion Value.unit Value.unit\n | const {c} : Value.Approx.Inversion (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n args_rev ≲ₐ args_rev' β†’\n Value.Approx.Inversion (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’\n Value.Approx.Inversion (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Eval.Indexed", "content": "inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where\n | var {n env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval.Indexed n env (Expr.var name idx) val\n | var_rec {n env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval.Indexed n env' expr val β†’\n Eval.Indexed n env (Expr.var name idx) val\n | unit {n env} :\n Eval.Indexed n env Expr.unit Value.unit\n | const {n env c} :\n Eval.Indexed n env (Expr.const c) (Value.const c)\n | constr {n env name} :\n Eval.Indexed n env (Expr.constr name) (Value.constr_app name [])\n | app {n n₁ nβ‚‚ env env' f body arg val val'} :\n n₁ + nβ‚‚ + 1 ≀ n β†’\n Eval.Indexed n₁ env f (Value.closure env' body) β†’\n Eval.Indexed (n₁ + 1) env arg val β†’\n Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’\n Eval.Indexed n env (Expr.app f arg) val'\n | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} :\n n' < n β†’\n Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval.Indexed n' env arg val β†’\n Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {n env name body} :\n Eval.Indexed n env (Expr.lambda name body) (Value.closure env body)\n | save {n n₁ nβ‚‚ env name value body val val'} :\n n₁ + nβ‚‚ ≀ n β†’\n Eval.Indexed n₁ env value val β†’\n Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’\n Eval.Indexed n env (Expr.save name value body) val'\n | branch_matches {n n' env name args_rev body val} :\n n' < n β†’\n Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {n env name name' args_rev next val} :\n name β‰  name' β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {n n' env name body val} :\n n' < n β†’\n Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval.Indexed n env (Expr.recur name body) val" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "Expr.Approx.Param.Indexed", "content": "def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Env", "content": "abbrev Env : Type := List Object\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Expr.Approx.Param", "content": "def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)" }, { "name": "Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Value.Approx.Indexed.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where\n | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit\n | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env" }, { "name": "Expr.Approx.Indexed'", "content": "def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" }, { "name": "Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" }, { "name": "Value.Approx.Indexed.Preservation", "content": "def Value.Approx.Indexed.Preservation (k : Nat) : Prop :=\n βˆ€ m n env env' e v,\n m + n < k β†’\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "List.forallβ‚‚_cons", "module": "Batteries.Data.List.Basic" }, { "name": "List.forallβ‚‚_same", "module": "Mathlib.Data.List.Forall2" } ]
[ { "name": "Expr.Approx.toIndexed", "content": "lemma Expr.Approx.toIndexed {e₁ eβ‚‚} : e₁ ≲ eβ‚‚ β†’ βˆ€ n, e₁ ≲'(n) eβ‚‚" }, { "name": "Value.Approx.Indexed.trans", "content": "@[trans]\nlemma Value.Approx.Indexed.trans {n v₁ vβ‚‚ v₃} : v₁ ≲α΅₯(n) vβ‚‚ β†’ vβ‚‚ ≲α΅₯ v₃ β†’ v₁ ≲α΅₯(n) v₃" }, { "name": "Value.Approx.invert", "content": "@[aesop unsafe destruct]\nlemma Value.Approx.invert {v v'} :\n v ≲α΅₯ v' β†’\n Value.Approx.Inversion v v'" }, { "name": "Env.Approx.toIndexed", "content": "lemma Env.Approx.toIndexed {env₁ envβ‚‚} : env₁ ≲ₑ envβ‚‚ β†’ βˆ€ n, env₁ ≲ₑ'(n) envβ‚‚" }, { "name": "Env.Approx.cons", "content": "lemma Env.Approx.cons {env₁ envβ‚‚ o₁ oβ‚‚} :\n o₁ ≲ₒ oβ‚‚ β†’ env₁ ≲ₑ envβ‚‚ β†’ (o₁ :: env₁) ≲ₑ (oβ‚‚ :: envβ‚‚)" }, { "name": "Object.Approx.toIndexed", "content": "lemma Object.Approx.toIndexed {o₁ oβ‚‚} : o₁ ≲ₒ oβ‚‚ β†’ βˆ€ n, o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Eval.deterministic", "content": "theorem Eval.deterministic {env e v₁ vβ‚‚} (h₁ : env ⊒ e ↦ v₁) (hβ‚‚ : env ⊒ e ↦ vβ‚‚) : v₁ = vβ‚‚" }, { "name": "Eval.toIndexed", "content": "lemma Eval.toIndexed {env e v} (h : env ⊒ e ↦ v) : βˆƒ n, env ⊒ e ↦(n) v" }, { "name": "Eval.Indexed.monotone", "content": "lemma Eval.Indexed.monotone {n n' env e v} (h : env ⊒ e ↦(n) v) (h' : n ≀ n') : env ⊒ e ↦(n') v" }, { "name": "Value.Approx.Indexed.preserved", "content": "theorem Value.Approx.Indexed.preserved :\n βˆ€ m n env env' e v,\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" }, { "name": "Value.Approx.Indexed.preserved'", "content": "lemma Value.Approx.Indexed.preserved' {k} : Preservation k" }, { "name": "Env.Approx.Indexed'.refl", "content": "@[refl]\nlemma Env.Approx.Indexed'.refl {n env} : env ≲ₑ'(n) env" }, { "name": "Value.Approx.Indexed.refl", "content": "@[refl]\nlemma Value.Approx.Indexed.refl {n} v : v ≲α΅₯(n) v" }, { "name": "Object.Approx.Indexed'.refl'", "content": "lemma Object.Approx.Indexed'.refl' {n o} (h : βˆ€ v, v ≲α΅₯(n) v) : o ≲ₒ'(n) o" }, { "name": "Env.Approx.Indexed'.refl'", "content": "lemma Env.Approx.Indexed'.refl' {n env} (h : βˆ€ v, v ≲α΅₯(n) v) : env ≲ₑ'(n) env" }, { "name": "Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "Object.Approx.Indexed'.refl", "content": "@[refl]\nlemma Object.Approx.Indexed'.refl {n o} : o ≲ₒ'(n) o" }, { "name": "Value.Approx.Indexed.preserved_step", "content": "lemma Value.Approx.Indexed.preserved_step {k} :\n (βˆ€ k' < k, Preservation k') β†’ Preservation k" }, { "name": "Expr.Approx.Param.Indexed.anti_monotone", "content": "lemma Expr.Approx.Param.Indexed.anti_monotone {n n' env₁ envβ‚‚ e₁ eβ‚‚}\n (h : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲(n')⟨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Expr.Approx.Indexed'.anti_monotone", "content": "lemma Expr.Approx.Indexed'.anti_monotone {n n' e₁ eβ‚‚}\n (h : e₁ ≲'(n) eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲'(n') eβ‚‚" }, { "name": "Env.Approx.Indexed'.delayed", "content": "lemma Env.Approx.Indexed'.delayed {n i : Nat} {env₁ envβ‚‚ env e}\n (h₁ : env₁ ≲ₑ'(n) envβ‚‚)\n (hβ‚‚ : env₁[i]? = some (Object.delayed env e)) :\n (βˆƒ env' e', e ≲(n)⟨env, env'⟩ e' ∧ envβ‚‚[i]? = some (Object.delayed env' e')) ∨\n βˆƒ env', env ≲ₑ'(n) env' ∧ envβ‚‚[i]? = some (Object.delayed env' e)" }, { "name": "Env.Approx.Indexed'.value", "content": "lemma Env.Approx.Indexed'.value {n i : Nat} {env env' v}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some (Object.value v)) :\n βˆƒ v', env'[i]? = some (Object.value v') ∧ v ≲α΅₯(n) v'" }, { "name": "Env.Approx.Indexed'.get", "content": "lemma Env.Approx.Indexed'.get {n i : Nat} {env env' o₁}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some o₁) :\n βˆƒ oβ‚‚, env'[i]? = some oβ‚‚ ∧ o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Value.Approx.Indexed.anti_monotone", "content": "lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚" }, { "name": "Value.Approx.Indexed.Preservation.anti_monotone", "content": "lemma Value.Approx.Indexed.Preservation.anti_monotone {k k'} (h : Value.Approx.Indexed.Preservation k) (h' : k' ≀ k) : Value.Approx.Indexed.Preservation k'" }, { "name": "Env.Approx.Indexed'.anti_monotone", "content": "lemma Env.Approx.Indexed'.anti_monotone {n n' env₁ envβ‚‚}\n (h : env₁ ≲ₑ'(n) envβ‚‚)\n (h' : n' ≀ n)\n : env₁ ≲ₑ'(n') envβ‚‚" }, { "name": "Object.Approx.Indexed'.anti_monotone", "content": "lemma Object.Approx.Indexed'.anti_monotone {n n' o₁ oβ‚‚} (h : o₁ ≲ₒ'(n) oβ‚‚) (h' : n' ≀ n) : o₁ ≲ₒ'(n') oβ‚‚" }, { "name": "Env.Approx.Indexed'.cons", "content": "lemma Env.Approx.Indexed'.cons {n o₁ oβ‚‚ env₁ envβ‚‚}\n (h₁ : o₁ ≲ₒ'(n) oβ‚‚)\n (hβ‚‚ : env₁ ≲ₑ'(n) envβ‚‚) :\n o₁ :: env₁ ≲ₑ'(n) oβ‚‚ :: envβ‚‚" }, { "name": "Env.Approx.Indexed'.concat", "content": "lemma Env.Approx.Indexed'.concat {n env₁ envβ‚‚ env₁' envβ‚‚'}\n (h₁ : env₁ ≲ₑ'(n) env₁')\n (hβ‚‚ : envβ‚‚ ≲ₑ'(n) envβ‚‚') :\n env₁ ++ envβ‚‚ ≲ₑ'(n) env₁' ++ envβ‚‚'" }, { "name": "Env.Approx.Indexed'.from_value", "content": "lemma Env.Approx.Indexed'.from_value {n l₁ lβ‚‚} (h : l₁ ≲ₐ(n) lβ‚‚) :\n List.map Object.value l₁ ≲ₑ'(n) List.map Object.value lβ‚‚" }, { "name": "Value.Approx.preserved", "content": "theorem Value.Approx.preserved :\n βˆ€ env env' e v,\n env ≲ₑ env' β†’\n env ⊒ e ↦ v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯ v'" }, { "name": "Value.Approx.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.constr_app {ctr_name args_rev args_rev'} :\n args_rev ≲ₐ args_rev' β†’\n Value.constr_app ctr_name args_rev ≲α΅₯ Value.constr_app ctr_name args_rev'" }, { "name": "Value.Approx.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ a₁ aβ‚‚,\n a₁ ≲α΅₯ aβ‚‚ β†’\n body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯ Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "Expr.Approx.Param.preserved", "content": "lemma Expr.Approx.Param.preserved {e e' env₁ envβ‚‚ env₃} :\n e β‰²βŸ¨env₁, envβ‚‚βŸ© e' β†’\n envβ‚‚ ≲ₑ env₃ β†’\n e β‰²βŸ¨env₁, envβ‚ƒβŸ© e'" }, { "name": "Expr.Approx.const", "content": "lemma Expr.Approx.const {c₁ cβ‚‚} :\n Expr.const c₁ ≲ Expr.const cβ‚‚ β†’\n c₁ = cβ‚‚" }, { "name": "Expr.Approx.preservation", "content": "lemma Expr.Approx.preservation {e₁ eβ‚‚} :\n e₁ ≲ eβ‚‚ ↔\n βˆ€ env v₁, env ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, env ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚" }, { "name": "Expr.Approx.to_preservation", "content": "lemma Expr.Approx.to_preservation {e₁ eβ‚‚} :\n e₁ ≲ eβ‚‚ β†’\n βˆ€ env v₁, env ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, env ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚" }, { "name": "Expr.Approx.from_preservation", "content": "lemma Expr.Approx.from_preservation {e₁ eβ‚‚}\n (h : βˆ€ env v₁, env ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, env ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)\n : e₁ ≲ eβ‚‚" } ]
[ { "name": "Juvix.Core.Main.Context.Indexed.Preserved", "content": "def Context.Indexed.Preserved (k : Nat) : Prop :=\n βˆ€ n m,\n n + m < k β†’\n βˆ€ e₁ eβ‚‚,\n e₁ ≲'(n + m) eβ‚‚ β†’ βˆ€ (C : Context) env₁ envβ‚‚ v₁,\n env₁ ≲ₑ'(n + m) envβ‚‚ β†’\n env₁ ⊒ C.subst e₁ ↦(n) v₁ β†’\n βˆƒ vβ‚‚, envβ‚‚ ⊒ C.subst eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(m) vβ‚‚" } ]
[ { "name": "Juvix.Core.Main.Expr.Approx.Context.Indexed.preserved_step", "content": "lemma Expr.Approx.Context.Indexed.preserved_step (k : Nat) :\n Context.Indexed.Preserved k β†’ Context.Indexed.Preserved (k + 1)" }, { "name": "Juvix.Core.Main.Expr.Approx.Context.Indexed.preserved", "content": "lemma Expr.Approx.Context.Indexed.preserved (k : Nat) :\n Context.Indexed.Preserved k" } ]
import Juvix.Core.Main.Semantics.Approx import Juvix.Core.Main.Semantics.Approx.Contextual namespace Juvix.Core.Main def Context.Indexed.Preserved (k : Nat) : Prop := βˆ€ n m, n + m < k β†’ βˆ€ e₁ eβ‚‚, e₁ ≲'(n + m) eβ‚‚ β†’ βˆ€ (C : Context) env₁ envβ‚‚ v₁, env₁ ≲ₑ'(n + m) envβ‚‚ β†’ env₁ ⊒ C.subst e₁ ↦(n) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ C.subst eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(m) vβ‚‚
lemma Expr.Approx.Context.preserved (e₁ eβ‚‚ : Expr) : e₁ ≲ eβ‚‚ β†’ βˆ€ (C : Context) env₁ envβ‚‚ v₁, env₁ ≲ₑ envβ‚‚ β†’ env₁ ⊒ C.subst e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ C.subst eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚ :=
:= by intro happrox C env₁ envβ‚‚ v₁ henv heval obtain ⟨n, heval'⟩ := Eval.toIndexed heval have happrox' : e₁ ≲'(n + 0) eβ‚‚ := by apply Expr.Approx.toIndexed happrox have henv' : env₁ ≲ₑ'(n + 0) envβ‚‚ := by apply Env.Approx.toIndexed henv obtain ⟨vβ‚‚, hevalβ‚‚, happroxβ‚‚βŸ© := Expr.Approx.Context.Indexed.preserved (n + 1) n 0 (by linarith) e₁ eβ‚‚ happrox' C env₁ envβ‚‚ v₁ henv' heval' have : βˆ€ m, v₁ ≲α΅₯(m) vβ‚‚ := by intro m have happrox_m : e₁ ≲'(n + m) eβ‚‚ := by apply Expr.Approx.toIndexed happrox have henv_m : env₁ ≲ₑ'(n + m) envβ‚‚ := by apply Env.Approx.toIndexed henv obtain ⟨vβ‚‚', hevalβ‚‚', happroxβ‚‚'⟩ := Expr.Approx.Context.Indexed.preserved (n + m + 1) n m (by linarith) e₁ eβ‚‚ happrox_m C env₁ envβ‚‚ v₁ henv_m heval' have : vβ‚‚ = vβ‚‚' := Eval.deterministic hevalβ‚‚ hevalβ‚‚' rw [this] assumption exists vβ‚‚
5
84
false
Semantics
252
Juvix.Core.Main.Value.Approx.closure
@[aesop unsafe apply] lemma Value.Approx.closure {env₁ body₁ envβ‚‚ bodyβ‚‚} : (βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’ Value.closure env₁ body₁ ≲α΅₯ Value.closure envβ‚‚ bodyβ‚‚
juvix-lean
Juvix/Core/Main/Semantics/Approx.lean
[ "import Juvix.Core.Main.Semantics.Approx.Indexed", "import Juvix.Utils" ]
[ { "name": "List", "module": "Init.Prelude" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "IsEmpty", "module": "Mathlib.Logic.IsEmpty" }, { "name": "List.map", "module": "Init.Prelude" } ]
[ { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.A", "content": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚\n\nsyntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'\n\nsyntax \"let \" ident \" := \" expr \" in \" expr : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" }, { "name": "Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" }, { "name": "Value.Approx.Indexed.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where\n | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit\n | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "Value.Approx.Indexed.Preservation", "content": "def Value.Approx.Indexed.Preservation (k : Nat) : Prop :=\n βˆ€ m n env env' e v,\n m + n < k β†’\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" }, { "name": "Expr.Approx.Param.Indexed", "content": "def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Eval.Indexed", "content": "inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where\n | var {n env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval.Indexed n env (Expr.var name idx) val\n | var_rec {n env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval.Indexed n env' expr val β†’\n Eval.Indexed n env (Expr.var name idx) val\n | unit {n env} :\n Eval.Indexed n env Expr.unit Value.unit\n | const {n env c} :\n Eval.Indexed n env (Expr.const c) (Value.const c)\n | constr {n env name} :\n Eval.Indexed n env (Expr.constr name) (Value.constr_app name [])\n | app {n n₁ nβ‚‚ env env' f body arg val val'} :\n n₁ + nβ‚‚ + 1 ≀ n β†’\n Eval.Indexed n₁ env f (Value.closure env' body) β†’\n Eval.Indexed (n₁ + 1) env arg val β†’\n Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’\n Eval.Indexed n env (Expr.app f arg) val'\n | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} :\n n' < n β†’\n Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval.Indexed n' env arg val β†’\n Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {n env name body} :\n Eval.Indexed n env (Expr.lambda name body) (Value.closure env body)\n | save {n n₁ nβ‚‚ env name value body val val'} :\n n₁ + nβ‚‚ ≀ n β†’\n Eval.Indexed n₁ env value val β†’\n Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’\n Eval.Indexed n env (Expr.save name value body) val'\n | branch_matches {n n' env name args_rev body val} :\n n' < n β†’\n Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {n env name name' args_rev next val} :\n name β‰  name' β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {n n' env name body val} :\n n' < n β†’\n Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval.Indexed n env (Expr.recur name body) val" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "Context", "content": "inductive Context : Type where\n | hole : Context\n | app_left : Context β†’ Expr β†’ Context\n | app_right : Expr β†’ Context β†’ Context\n | constr_app_left : Context β†’ Expr β†’ Context\n | constr_app_right : Expr β†’ Context β†’ Context\n | binop_left : (oper : BinaryOp) β†’ (arg₁ : Context) β†’ (argβ‚‚ : Expr) β†’ Context\n | binop_right : (oper : BinaryOp) β†’ (arg₁ : Expr) β†’ (argβ‚‚ : Context) β†’ Context\n | lambda : (var_name : String) β†’ (body : Context) β†’ Context\n | save_left : (var_name : String) β†’ (value : Context) β†’ (body : Expr) β†’ Context\n | save_right : (var_name : String) β†’ (value : Expr) β†’ (body : Context) β†’ Context\n | branch_left : (constr : Name) β†’ (var_names : List Name) β†’ (body : Context) β†’ (next : Expr) β†’ Context\n | branch_right : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Context) β†’ Context\n | recur : (var_name : Name) β†’ (ctx : Context) β†’ Context\n deriving Inhabited, BEq" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "Expr.Approx.Indexed'", "content": "def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "IsEmpty.forall_iff", "module": "Mathlib.Logic.IsEmpty" }, { "name": "implies_true", "module": "Init.SimpLemmas" }, { "name": "nonpos_iff_eq_zero", "module": "Mathlib.Algebra.Order.Monoid.Canonical.Defs" }, { "name": "not_lt_zero'", "module": "Mathlib.Algebra.Order.GroupWithZero.Canonical" } ]
[ { "name": "Value.Approx.Indexed.invert", "content": "@[aesop unsafe destruct]\nlemma Value.Approx.Indexed.invert {n v v'} :\n v ≲α΅₯(n) v' β†’\n Value.Approx.Indexed.Inversion n v v'" }, { "name": "Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "forallβ‚‚_trans'", "content": "theorem forallβ‚‚_trans' {Ξ±} {P Q R : Ξ± β†’ Ξ± β†’ Prop} {l₁ lβ‚‚ l₃}\n (h : βˆ€ x y z, P x y β†’ Q y z β†’ R x z)\n (h₁ : List.Forallβ‚‚ P l₁ lβ‚‚)\n (hβ‚‚ : List.Forallβ‚‚ Q lβ‚‚ l₃)\n : List.Forallβ‚‚ R l₁ l₃" }, { "name": "Value.Approx.Indexed.preserved", "content": "theorem Value.Approx.Indexed.preserved :\n βˆ€ m n env env' e v,\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" }, { "name": "Value.Approx.Indexed.preserved'", "content": "lemma Value.Approx.Indexed.preserved' {k} : Preservation k" }, { "name": "Env.Approx.Indexed'.refl", "content": "@[refl]\nlemma Env.Approx.Indexed'.refl {n env} : env ≲ₑ'(n) env" }, { "name": "Value.Approx.Indexed.refl", "content": "@[refl]\nlemma Value.Approx.Indexed.refl {n} v : v ≲α΅₯(n) v" }, { "name": "Object.Approx.Indexed'.refl'", "content": "lemma Object.Approx.Indexed'.refl' {n o} (h : βˆ€ v, v ≲α΅₯(n) v) : o ≲ₒ'(n) o" }, { "name": "Env.Approx.Indexed'.refl'", "content": "lemma Env.Approx.Indexed'.refl' {n env} (h : βˆ€ v, v ≲α΅₯(n) v) : env ≲ₑ'(n) env" }, { "name": "Object.Approx.Indexed'.refl", "content": "@[refl]\nlemma Object.Approx.Indexed'.refl {n o} : o ≲ₒ'(n) o" }, { "name": "Value.Approx.Indexed.preserved_step", "content": "lemma Value.Approx.Indexed.preserved_step {k} :\n (βˆ€ k' < k, Preservation k') β†’ Preservation k" }, { "name": "Expr.Approx.Param.Indexed.anti_monotone", "content": "lemma Expr.Approx.Param.Indexed.anti_monotone {n n' env₁ envβ‚‚ e₁ eβ‚‚}\n (h : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲(n')⟨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Expr.Approx.Indexed'.anti_monotone", "content": "lemma Expr.Approx.Indexed'.anti_monotone {n n' e₁ eβ‚‚}\n (h : e₁ ≲'(n) eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲'(n') eβ‚‚" }, { "name": "Env.Approx.Indexed'.delayed", "content": "lemma Env.Approx.Indexed'.delayed {n i : Nat} {env₁ envβ‚‚ env e}\n (h₁ : env₁ ≲ₑ'(n) envβ‚‚)\n (hβ‚‚ : env₁[i]? = some (Object.delayed env e)) :\n (βˆƒ env' e', e ≲(n)⟨env, env'⟩ e' ∧ envβ‚‚[i]? = some (Object.delayed env' e')) ∨\n βˆƒ env', env ≲ₑ'(n) env' ∧ envβ‚‚[i]? = some (Object.delayed env' e)" }, { "name": "Env.Approx.Indexed'.value", "content": "lemma Env.Approx.Indexed'.value {n i : Nat} {env env' v}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some (Object.value v)) :\n βˆƒ v', env'[i]? = some (Object.value v') ∧ v ≲α΅₯(n) v'" }, { "name": "Env.Approx.Indexed'.get", "content": "lemma Env.Approx.Indexed'.get {n i : Nat} {env env' o₁}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some o₁) :\n βˆƒ oβ‚‚, env'[i]? = some oβ‚‚ ∧ o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Value.Approx.Indexed.anti_monotone", "content": "lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚" }, { "name": "Value.Approx.Indexed.Preservation.anti_monotone", "content": "lemma Value.Approx.Indexed.Preservation.anti_monotone {k k'} (h : Value.Approx.Indexed.Preservation k) (h' : k' ≀ k) : Value.Approx.Indexed.Preservation k'" }, { "name": "Env.Approx.Indexed'.anti_monotone", "content": "lemma Env.Approx.Indexed'.anti_monotone {n n' env₁ envβ‚‚}\n (h : env₁ ≲ₑ'(n) envβ‚‚)\n (h' : n' ≀ n)\n : env₁ ≲ₑ'(n') envβ‚‚" }, { "name": "Object.Approx.Indexed'.anti_monotone", "content": "lemma Object.Approx.Indexed'.anti_monotone {n n' o₁ oβ‚‚} (h : o₁ ≲ₒ'(n) oβ‚‚) (h' : n' ≀ n) : o₁ ≲ₒ'(n') oβ‚‚" }, { "name": "Env.Approx.Indexed'.cons", "content": "lemma Env.Approx.Indexed'.cons {n o₁ oβ‚‚ env₁ envβ‚‚}\n (h₁ : o₁ ≲ₒ'(n) oβ‚‚)\n (hβ‚‚ : env₁ ≲ₑ'(n) envβ‚‚) :\n o₁ :: env₁ ≲ₑ'(n) oβ‚‚ :: envβ‚‚" }, { "name": "Env.Approx.Indexed'.concat", "content": "lemma Env.Approx.Indexed'.concat {n env₁ envβ‚‚ env₁' envβ‚‚'}\n (h₁ : env₁ ≲ₑ'(n) env₁')\n (hβ‚‚ : envβ‚‚ ≲ₑ'(n) envβ‚‚') :\n env₁ ++ envβ‚‚ ≲ₑ'(n) env₁' ++ envβ‚‚'" }, { "name": "Env.Approx.Indexed'.from_value", "content": "lemma Env.Approx.Indexed'.from_value {n l₁ lβ‚‚} (h : l₁ ≲ₐ(n) lβ‚‚) :\n List.map Object.value l₁ ≲ₑ'(n) List.map Object.value lβ‚‚" } ]
[ { "name": "Juvix.Core.Main.Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Juvix.Core.Main.Expr.Approx.Param", "content": "def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)" }, { "name": "Juvix.Core.Main.Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Juvix.Core.Main.Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "Juvix.Core.Main.Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Inversion : Value -> Value -> Prop where\n | unit : Value.Approx.Inversion Value.unit Value.unit\n | const {c} : Value.Approx.Inversion (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n args_rev ≲ₐ args_rev' β†’\n Value.Approx.Inversion (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’\n Value.Approx.Inversion (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.invert", "content": "@[aesop unsafe destruct]\nlemma Value.Approx.invert {v v'} :\n v ≲α΅₯ v' β†’\n Value.Approx.Inversion v v'" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.trans", "content": "@[trans]\nlemma Value.Approx.Indexed.trans {n v₁ vβ‚‚ v₃} : v₁ ≲α΅₯(n) vβ‚‚ β†’ vβ‚‚ ≲α΅₯ v₃ β†’ v₁ ≲α΅₯(n) v₃" } ]
import Juvix.Core.Main.Semantics.Approx.Indexed namespace Juvix.Core.Main def Value.Approx (v v' : Value) : Prop := βˆ€ n, v ≲α΅₯(n) v' notation:40 v:40 " ≲α΅₯ " v':40 => Value.Approx v v' notation:40 args₁:40 " ≲ₐ " argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚ def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚) notation:40 e:40 " β‰²βŸ¨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param env env' e e' inductive Object.Approx : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ Object.Approx notation:40 v:40 " ≲ₒ " v':40 => Object.Approx v v' notation:40 env₁:40 " ≲ₑ " envβ‚‚:40 => Env.Approx env₁ envβ‚‚ def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop := βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ notation:40 e₁:40 " ≲ " eβ‚‚:40 => Expr.Approx e₁ eβ‚‚ @[aesop safe cases] inductive Value.Approx.Inversion : Value -> Value -> Prop where | unit : Value.Approx.Inversion Value.unit Value.unit | const {c} : Value.Approx.Inversion (Value.const c) (Value.const c) | constr_app {ctr_name args_rev args_rev'} : args_rev ≲ₐ args_rev' β†’ Value.Approx.Inversion (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev') | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} : (βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’ Value.Approx.Inversion (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)
@[aesop unsafe apply] lemma Value.Approx.closure {env₁ body₁ envβ‚‚ bodyβ‚‚} : (βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’ Value.closure env₁ body₁ ≲α΅₯ Value.closure envβ‚‚ bodyβ‚‚ :=
:= by intro h n apply Value.Approx.Indexed.closure intro n₁ nβ‚‚ hn a₁ aβ‚‚ v₁ happrox heval have h₁ : βˆƒ v₁', aβ‚‚ ∷ env₁ ⊒ body₁ ↦ v₁' ∧ v₁ ≲α΅₯(nβ‚‚) v₁' := by apply Indexed.preserved nβ‚‚ n₁ (a₁ ∷ env₁) (aβ‚‚ ∷ env₁) body₁ v₁ Β· simp [Env.Approx.Indexed'] constructor Β· constructor have : nβ‚‚ + n₁ = n₁ + nβ‚‚ := by linarith rw [this] exact happrox Β· intros rfl Β· assumption obtain ⟨v₁', heval', happrox'⟩ := h₁ obtain ⟨vβ‚‚, hevalβ‚‚, happroxβ‚‚βŸ© := h aβ‚‚ aβ‚‚ (by rfl) v₁' heval' exists vβ‚‚ constructor Β· assumption Β· apply Value.Approx.Indexed.trans <;> assumption
4
68
false
Semantics
253
Juvix.Core.Main.Object.Approx.Indexed'.anti_monotone
lemma Object.Approx.Indexed'.anti_monotone {n n' o₁ oβ‚‚} (h : o₁ ≲ₒ'(n) oβ‚‚) (h' : n' ≀ n) : o₁ ≲ₒ'(n') oβ‚‚ := match h with | @Object.Approx.Indexed'.value n v₁ vβ‚‚ happrox => by apply Object.Approx.Indexed'.value Β· apply Value.Approx.Indexed.anti_monotone Β· assumption Β· assumption | @Object.Approx.Indexed'.delayed n env₁ envβ‚‚ e₁ eβ‚‚ happrox => by apply Object.Approx.Indexed'.delayed apply Expr.Approx.Param.Indexed.anti_monotone Β· assumption Β· assumption | @Object.Approx.Indexed'.delayed_eq n env₁ envβ‚‚ e happrox => Object.Approx.Indexed'.delayed_eq (Env.Approx.Indexed'.anti_monotone happrox h')
juvix-lean
Juvix/Core/Main/Semantics/Approx/Indexed.lean
[ "import Juvix.Utils", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Mathlib.Tactic.Linarith", "import Mathlib.Data.List.Forall2", "import Juvix.Core.Main.Semantics.Eval", "import Aesop" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "reduceCtorEq", "module": "Lean.Meta.Tactic.Simp.BuiltinSimprocs.Core" }, { "name": "List.Forallβ‚‚.cons", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.nil", "module": "Batteries.Data.List.Basic" } ]
[ { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Expr.Approx.Param", "content": "def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "and_self", "module": "Init.SimpLemmas" }, { "name": "exists_and_left", "module": "Init.PropLemmas" }, { "name": "exists_const", "module": "Init.PropLemmas" }, { "name": "exists_eq_left'", "module": "Init.PropLemmas" }, { "name": "false_and", "module": "Init.SimpLemmas" }, { "name": "false_or", "module": "Init.SimpLemmas" }, { "name": "implies_true", "module": "Init.SimpLemmas" }, { "name": "or_false", "module": "Init.SimpLemmas" }, { "name": "true_and", "module": "Init.SimpLemmas" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" }, { "name": "Juvix.Core.Main.Expr.Approx.Param.Indexed", "content": "def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Juvix.Core.Main.Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.anti_monotone", "content": "lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚" }, { "name": "Juvix.Core.Main.Expr.Approx.Param.Indexed.anti_monotone", "content": "lemma Expr.Approx.Param.Indexed.anti_monotone {n n' env₁ envβ‚‚ e₁ eβ‚‚}\n (h : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲(n')⟨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.anti_monotone", "content": " lemma Env.Approx.Indexed'.anti_monotone {n n' env₁ envβ‚‚}\n (h : env₁ ≲ₑ'(n) envβ‚‚)\n (h' : n' ≀ n)\n : env₁ ≲ₑ'(n') envβ‚‚" } ]
import Juvix.Core.Main.Semantics.Eval import Juvix.Core.Main.Semantics.Eval.Indexed import Juvix.Utils import Mathlib.Tactic.Linarith import Mathlib.Data.List.Forall2 import Aesop namespace Juvix.Core.Main def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop := (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨ (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨ (βˆƒ ctr_name args_rev args_rev', v₁ = Value.constr_app ctr_name args_rev ∧ vβ‚‚ = Value.constr_app ctr_name args_rev' ∧ (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨ (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚, v₁ = Value.closure env₁ body₁ ∧ vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧ (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’ βˆ€ a₁ aβ‚‚ r₁, Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’ a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’ βˆƒ rβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧ Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚)) notation:40 v:40 " ≲α΅₯(" n:40 ") " v':40 => Value.Approx.Indexed n v v' notation:40 args₁:40 " ≲ₐ(" n:40 ") " argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚ def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) notation:40 e:40 " ≲(" n:40 ")⟨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param.Indexed n env env' e e' inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯(n) vβ‚‚ β†’ Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) | delayed_eq {env₁ envβ‚‚ e} : List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e) def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ (Object.Approx.Indexed' n) notation:40 v:40 " ≲ₒ'(" n:40 ") " v':40 => Object.Approx.Indexed' n v v' notation:40 env₁:40 " ≲ₑ'(" n:40 ") " envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚ notation:40 e:40 " ≲'(" n:40 ") " e':40 => Expr.Approx.Indexed' n e e'
lemma Object.Approx.Indexed'.anti_monotone {n n' o₁ oβ‚‚} (h : o₁ ≲ₒ'(n) oβ‚‚) (h' : n' ≀ n) : o₁ ≲ₒ'(n') oβ‚‚ :=
:= match h with | @Object.Approx.Indexed'.value n v₁ vβ‚‚ happrox => by apply Object.Approx.Indexed'.value Β· apply Value.Approx.Indexed.anti_monotone Β· assumption Β· assumption | @Object.Approx.Indexed'.delayed n env₁ envβ‚‚ e₁ eβ‚‚ happrox => by apply Object.Approx.Indexed'.delayed apply Expr.Approx.Param.Indexed.anti_monotone Β· assumption Β· assumption | @Object.Approx.Indexed'.delayed_eq n env₁ envβ‚‚ e happrox => Object.Approx.Indexed'.delayed_eq (Env.Approx.Indexed'.anti_monotone happrox h')
3
47
false
Semantics
254
Juvix.Core.Main.Value.Approx.closure_inv
lemma Value.Approx.closure_inv {env₁ body₁ envβ‚‚ bodyβ‚‚} (h : Value.closure env₁ body₁ ≲α΅₯ Value.closure envβ‚‚ bodyβ‚‚) : βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚
juvix-lean
Juvix/Core/Main/Semantics/Approx.lean
[ "import Juvix.Core.Main.Semantics.Approx.Indexed", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Juvix.Utils", "import Juvix.Core.Main.Semantics.Eval" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "IsEmpty", "module": "Mathlib.Logic.IsEmpty" }, { "name": "List.map", "module": "Init.Prelude" } ]
[ { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.A", "content": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚\n\nsyntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'\n\nsyntax \"let \" ident \" := \" expr \" in \" expr : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" }, { "name": "Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" }, { "name": "Value.Approx.Indexed.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where\n | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit\n | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "Value.Approx.Indexed.Preservation", "content": "def Value.Approx.Indexed.Preservation (k : Nat) : Prop :=\n βˆ€ m n env env' e v,\n m + n < k β†’\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" }, { "name": "Expr.Approx.Param.Indexed", "content": "def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Eval.Indexed", "content": "inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where\n | var {n env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval.Indexed n env (Expr.var name idx) val\n | var_rec {n env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval.Indexed n env' expr val β†’\n Eval.Indexed n env (Expr.var name idx) val\n | unit {n env} :\n Eval.Indexed n env Expr.unit Value.unit\n | const {n env c} :\n Eval.Indexed n env (Expr.const c) (Value.const c)\n | constr {n env name} :\n Eval.Indexed n env (Expr.constr name) (Value.constr_app name [])\n | app {n n₁ nβ‚‚ env env' f body arg val val'} :\n n₁ + nβ‚‚ + 1 ≀ n β†’\n Eval.Indexed n₁ env f (Value.closure env' body) β†’\n Eval.Indexed (n₁ + 1) env arg val β†’\n Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’\n Eval.Indexed n env (Expr.app f arg) val'\n | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} :\n n' < n β†’\n Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval.Indexed n' env arg val β†’\n Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {n env name body} :\n Eval.Indexed n env (Expr.lambda name body) (Value.closure env body)\n | save {n n₁ nβ‚‚ env name value body val val'} :\n n₁ + nβ‚‚ ≀ n β†’\n Eval.Indexed n₁ env value val β†’\n Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’\n Eval.Indexed n env (Expr.save name value body) val'\n | branch_matches {n n' env name args_rev body val} :\n n' < n β†’\n Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {n env name name' args_rev next val} :\n name β‰  name' β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {n n' env name body val} :\n n' < n β†’\n Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval.Indexed n env (Expr.recur name body) val" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "Context", "content": "inductive Context : Type where\n | hole : Context\n | app_left : Context β†’ Expr β†’ Context\n | app_right : Expr β†’ Context β†’ Context\n | constr_app_left : Context β†’ Expr β†’ Context\n | constr_app_right : Expr β†’ Context β†’ Context\n | binop_left : (oper : BinaryOp) β†’ (arg₁ : Context) β†’ (argβ‚‚ : Expr) β†’ Context\n | binop_right : (oper : BinaryOp) β†’ (arg₁ : Expr) β†’ (argβ‚‚ : Context) β†’ Context\n | lambda : (var_name : String) β†’ (body : Context) β†’ Context\n | save_left : (var_name : String) β†’ (value : Context) β†’ (body : Expr) β†’ Context\n | save_right : (var_name : String) β†’ (value : Expr) β†’ (body : Context) β†’ Context\n | branch_left : (constr : Name) β†’ (var_names : List Name) β†’ (body : Context) β†’ (next : Expr) β†’ Context\n | branch_right : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Context) β†’ Context\n | recur : (var_name : Name) β†’ (ctx : Context) β†’ Context\n deriving Inhabited, BEq" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "Expr.Approx.Indexed'", "content": "def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "IsEmpty.forall_iff", "module": "Mathlib.Logic.IsEmpty" }, { "name": "implies_true", "module": "Init.SimpLemmas" }, { "name": "nonpos_iff_eq_zero", "module": "Mathlib.Algebra.Order.Monoid.Canonical.Defs" }, { "name": "not_lt_zero'", "module": "Mathlib.Algebra.Order.GroupWithZero.Canonical" } ]
[ { "name": "Value.Approx.Indexed.invert", "content": "@[aesop unsafe destruct]\nlemma Value.Approx.Indexed.invert {n v v'} :\n v ≲α΅₯(n) v' β†’\n Value.Approx.Indexed.Inversion n v v'" }, { "name": "Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "forallβ‚‚_trans'", "content": "theorem forallβ‚‚_trans' {Ξ±} {P Q R : Ξ± β†’ Ξ± β†’ Prop} {l₁ lβ‚‚ l₃}\n (h : βˆ€ x y z, P x y β†’ Q y z β†’ R x z)\n (h₁ : List.Forallβ‚‚ P l₁ lβ‚‚)\n (hβ‚‚ : List.Forallβ‚‚ Q lβ‚‚ l₃)\n : List.Forallβ‚‚ R l₁ l₃" }, { "name": "Value.Approx.Indexed.preserved", "content": "theorem Value.Approx.Indexed.preserved :\n βˆ€ m n env env' e v,\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" }, { "name": "Value.Approx.Indexed.preserved'", "content": "lemma Value.Approx.Indexed.preserved' {k} : Preservation k" }, { "name": "Env.Approx.Indexed'.refl", "content": "@[refl]\nlemma Env.Approx.Indexed'.refl {n env} : env ≲ₑ'(n) env" }, { "name": "Value.Approx.Indexed.refl", "content": "@[refl]\nlemma Value.Approx.Indexed.refl {n} v : v ≲α΅₯(n) v" }, { "name": "Object.Approx.Indexed'.refl'", "content": "lemma Object.Approx.Indexed'.refl' {n o} (h : βˆ€ v, v ≲α΅₯(n) v) : o ≲ₒ'(n) o" }, { "name": "Env.Approx.Indexed'.refl'", "content": "lemma Env.Approx.Indexed'.refl' {n env} (h : βˆ€ v, v ≲α΅₯(n) v) : env ≲ₑ'(n) env" }, { "name": "Object.Approx.Indexed'.refl", "content": "@[refl]\nlemma Object.Approx.Indexed'.refl {n o} : o ≲ₒ'(n) o" }, { "name": "Value.Approx.Indexed.preserved_step", "content": "lemma Value.Approx.Indexed.preserved_step {k} :\n (βˆ€ k' < k, Preservation k') β†’ Preservation k" }, { "name": "Expr.Approx.Param.Indexed.anti_monotone", "content": "lemma Expr.Approx.Param.Indexed.anti_monotone {n n' env₁ envβ‚‚ e₁ eβ‚‚}\n (h : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲(n')⟨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Expr.Approx.Indexed'.anti_monotone", "content": "lemma Expr.Approx.Indexed'.anti_monotone {n n' e₁ eβ‚‚}\n (h : e₁ ≲'(n) eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲'(n') eβ‚‚" }, { "name": "Env.Approx.Indexed'.delayed", "content": "lemma Env.Approx.Indexed'.delayed {n i : Nat} {env₁ envβ‚‚ env e}\n (h₁ : env₁ ≲ₑ'(n) envβ‚‚)\n (hβ‚‚ : env₁[i]? = some (Object.delayed env e)) :\n (βˆƒ env' e', e ≲(n)⟨env, env'⟩ e' ∧ envβ‚‚[i]? = some (Object.delayed env' e')) ∨\n βˆƒ env', env ≲ₑ'(n) env' ∧ envβ‚‚[i]? = some (Object.delayed env' e)" }, { "name": "Env.Approx.Indexed'.value", "content": "lemma Env.Approx.Indexed'.value {n i : Nat} {env env' v}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some (Object.value v)) :\n βˆƒ v', env'[i]? = some (Object.value v') ∧ v ≲α΅₯(n) v'" }, { "name": "Env.Approx.Indexed'.get", "content": "lemma Env.Approx.Indexed'.get {n i : Nat} {env env' o₁}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some o₁) :\n βˆƒ oβ‚‚, env'[i]? = some oβ‚‚ ∧ o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Value.Approx.Indexed.anti_monotone", "content": "lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚" }, { "name": "Value.Approx.Indexed.Preservation.anti_monotone", "content": "lemma Value.Approx.Indexed.Preservation.anti_monotone {k k'} (h : Value.Approx.Indexed.Preservation k) (h' : k' ≀ k) : Value.Approx.Indexed.Preservation k'" }, { "name": "Env.Approx.Indexed'.anti_monotone", "content": "lemma Env.Approx.Indexed'.anti_monotone {n n' env₁ envβ‚‚}\n (h : env₁ ≲ₑ'(n) envβ‚‚)\n (h' : n' ≀ n)\n : env₁ ≲ₑ'(n') envβ‚‚" }, { "name": "Object.Approx.Indexed'.anti_monotone", "content": "lemma Object.Approx.Indexed'.anti_monotone {n n' o₁ oβ‚‚} (h : o₁ ≲ₒ'(n) oβ‚‚) (h' : n' ≀ n) : o₁ ≲ₒ'(n') oβ‚‚" }, { "name": "Env.Approx.Indexed'.cons", "content": "lemma Env.Approx.Indexed'.cons {n o₁ oβ‚‚ env₁ envβ‚‚}\n (h₁ : o₁ ≲ₒ'(n) oβ‚‚)\n (hβ‚‚ : env₁ ≲ₑ'(n) envβ‚‚) :\n o₁ :: env₁ ≲ₑ'(n) oβ‚‚ :: envβ‚‚" }, { "name": "Env.Approx.Indexed'.concat", "content": "lemma Env.Approx.Indexed'.concat {n env₁ envβ‚‚ env₁' envβ‚‚'}\n (h₁ : env₁ ≲ₑ'(n) env₁')\n (hβ‚‚ : envβ‚‚ ≲ₑ'(n) envβ‚‚') :\n env₁ ++ envβ‚‚ ≲ₑ'(n) env₁' ++ envβ‚‚'" }, { "name": "Env.Approx.Indexed'.from_value", "content": "lemma Env.Approx.Indexed'.from_value {n l₁ lβ‚‚} (h : l₁ ≲ₐ(n) lβ‚‚) :\n List.map Object.value l₁ ≲ₑ'(n) List.map Object.value lβ‚‚" }, { "name": "Eval.deterministic", "content": "theorem Eval.deterministic {env e v₁ vβ‚‚} (h₁ : env ⊒ e ↦ v₁) (hβ‚‚ : env ⊒ e ↦ vβ‚‚) : v₁ = vβ‚‚" }, { "name": "Eval.toIndexed", "content": "lemma Eval.toIndexed {env e v} (h : env ⊒ e ↦ v) : βˆƒ n, env ⊒ e ↦(n) v" }, { "name": "Eval.Indexed.monotone", "content": "lemma Eval.Indexed.monotone {n n' env e v} (h : env ⊒ e ↦(n) v) (h' : n ≀ n') : env ⊒ e ↦(n') v" } ]
[ { "name": "Juvix.Core.Main.Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Juvix.Core.Main.Expr.Approx.Param", "content": "def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)" }, { "name": "Juvix.Core.Main.Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Juvix.Core.Main.Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "Juvix.Core.Main.Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" } ]
[]
import Juvix.Core.Main.Semantics.Approx.Indexed namespace Juvix.Core.Main def Value.Approx (v v' : Value) : Prop := βˆ€ n, v ≲α΅₯(n) v' notation:40 v:40 " ≲α΅₯ " v':40 => Value.Approx v v' notation:40 args₁:40 " ≲ₐ " argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚ def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚) notation:40 e:40 " β‰²βŸ¨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param env env' e e' inductive Object.Approx : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ Object.Approx notation:40 v:40 " ≲ₒ " v':40 => Object.Approx v v' notation:40 env₁:40 " ≲ₑ " envβ‚‚:40 => Env.Approx env₁ envβ‚‚ def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop := βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ notation:40 e₁:40 " ≲ " eβ‚‚:40 => Expr.Approx e₁ eβ‚‚
lemma Value.Approx.closure_inv {env₁ body₁ envβ‚‚ bodyβ‚‚} (h : Value.closure env₁ body₁ ≲α΅₯ Value.closure envβ‚‚ bodyβ‚‚) : βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚ :=
:= by intro a₁ aβ‚‚ ha v₁ h' suffices βˆ€ n, βˆƒ vβ‚‚, (aβ‚‚ ∷ envβ‚‚) ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(n) vβ‚‚ by obtain ⟨vβ‚‚, _, _⟩ := this 0 exists vβ‚‚ constructor Β· assumption Β· intro n obtain ⟨vβ‚‚', _, _⟩ := this n have : vβ‚‚ = vβ‚‚' := by apply Eval.deterministic <;> assumption subst this simp_all only intro nβ‚‚ obtain ⟨n₁, h''⟩ := Eval.toIndexed h' invert (h (n₁ + nβ‚‚ + 1)) case closure ch => apply ch (n₁ := n₁) (nβ‚‚ := nβ‚‚) Β· linarith Β· apply ha Β· assumption
5
72
false
Semantics
255
Juvix.Core.Main.Value.Approx.preserved
theorem Value.Approx.preserved : βˆ€ env env' e v, env ≲ₑ env' β†’ env ⊒ e ↦ v β†’ βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯ v'
juvix-lean
Juvix/Core/Main/Semantics/Approx.lean
[ "import Juvix.Core.Main.Semantics.Approx.Indexed", "import Juvix.Core.Main.Semantics.Eval", "import Juvix.Core.Main.Semantics.Eval.Indexed" ]
[ { "name": "List", "module": "Init.Prelude" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚.cons", "module": "Batteries.Data.List.Basic" }, { "name": "List.map", "module": "Init.Prelude" } ]
[ { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'\n\nsyntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))\n\nsyntax \"let \" ident \" := \" expr \" in \" expr : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" }, { "name": "Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Eval.Indexed", "content": "inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where\n | var {n env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval.Indexed n env (Expr.var name idx) val\n | var_rec {n env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval.Indexed n env' expr val β†’\n Eval.Indexed n env (Expr.var name idx) val\n | unit {n env} :\n Eval.Indexed n env Expr.unit Value.unit\n | const {n env c} :\n Eval.Indexed n env (Expr.const c) (Value.const c)\n | constr {n env name} :\n Eval.Indexed n env (Expr.constr name) (Value.constr_app name [])\n | app {n n₁ nβ‚‚ env env' f body arg val val'} :\n n₁ + nβ‚‚ + 1 ≀ n β†’\n Eval.Indexed n₁ env f (Value.closure env' body) β†’\n Eval.Indexed (n₁ + 1) env arg val β†’\n Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’\n Eval.Indexed n env (Expr.app f arg) val'\n | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} :\n n' < n β†’\n Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval.Indexed n' env arg val β†’\n Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {n env name body} :\n Eval.Indexed n env (Expr.lambda name body) (Value.closure env body)\n | save {n n₁ nβ‚‚ env name value body val val'} :\n n₁ + nβ‚‚ ≀ n β†’\n Eval.Indexed n₁ env value val β†’\n Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’\n Eval.Indexed n env (Expr.save name value body) val'\n | branch_matches {n n' env name args_rev body val} :\n n' < n β†’\n Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {n env name name' args_rev next val} :\n name β‰  name' β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {n n' env name body val} :\n n' < n β†’\n Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval.Indexed n env (Expr.recur name body) val" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "Value.Approx.Indexed.Preservation", "content": "def Value.Approx.Indexed.Preservation (k : Nat) : Prop :=\n βˆ€ m n env env' e v,\n m + n < k β†’\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" }, { "name": "Value.Approx.Indexed.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where\n | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit\n | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "Expr.Approx.Param.Indexed", "content": "def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Context", "content": "inductive Context : Type where\n | hole : Context\n | app_left : Context β†’ Expr β†’ Context\n | app_right : Expr β†’ Context β†’ Context\n | constr_app_left : Context β†’ Expr β†’ Context\n | constr_app_right : Expr β†’ Context β†’ Context\n | binop_left : (oper : BinaryOp) β†’ (arg₁ : Context) β†’ (argβ‚‚ : Expr) β†’ Context\n | binop_right : (oper : BinaryOp) β†’ (arg₁ : Expr) β†’ (argβ‚‚ : Context) β†’ Context\n | lambda : (var_name : String) β†’ (body : Context) β†’ Context\n | save_left : (var_name : String) β†’ (value : Context) β†’ (body : Expr) β†’ Context\n | save_right : (var_name : String) β†’ (value : Expr) β†’ (body : Context) β†’ Context\n | branch_left : (constr : Name) β†’ (var_names : List Name) β†’ (body : Context) β†’ (next : Expr) β†’ Context\n | branch_right : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Context) β†’ Context\n | recur : (var_name : Name) β†’ (ctx : Context) β†’ Context\n deriving Inhabited, BEq" }, { "name": "Expr.Approx.Indexed'", "content": "def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Eval.Indexed.toEval", "content": "lemma Eval.Indexed.toEval {n env e v} (h : env ⊒ e ↦(n) v) : env ⊒ e ↦ v" }, { "name": "Value.Approx.Indexed.preserved", "content": "theorem Value.Approx.Indexed.preserved :\n βˆ€ m n env env' e v,\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" }, { "name": "Value.Approx.Indexed.preserved'", "content": "lemma Value.Approx.Indexed.preserved' {k} : Preservation k" }, { "name": "Env.Approx.Indexed'.refl", "content": "@[refl]\nlemma Env.Approx.Indexed'.refl {n env} : env ≲ₑ'(n) env" }, { "name": "Value.Approx.Indexed.refl", "content": "@[refl]\nlemma Value.Approx.Indexed.refl {n} v : v ≲α΅₯(n) v" }, { "name": "Object.Approx.Indexed'.refl'", "content": "lemma Object.Approx.Indexed'.refl' {n o} (h : βˆ€ v, v ≲α΅₯(n) v) : o ≲ₒ'(n) o" }, { "name": "Env.Approx.Indexed'.refl'", "content": "lemma Env.Approx.Indexed'.refl' {n env} (h : βˆ€ v, v ≲α΅₯(n) v) : env ≲ₑ'(n) env" }, { "name": "Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "Object.Approx.Indexed'.refl", "content": "@[refl]\nlemma Object.Approx.Indexed'.refl {n o} : o ≲ₒ'(n) o" }, { "name": "Value.Approx.Indexed.preserved_step", "content": "lemma Value.Approx.Indexed.preserved_step {k} :\n (βˆ€ k' < k, Preservation k') β†’ Preservation k" }, { "name": "Expr.Approx.Param.Indexed.anti_monotone", "content": "lemma Expr.Approx.Param.Indexed.anti_monotone {n n' env₁ envβ‚‚ e₁ eβ‚‚}\n (h : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲(n')⟨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Expr.Approx.Indexed'.anti_monotone", "content": "lemma Expr.Approx.Indexed'.anti_monotone {n n' e₁ eβ‚‚}\n (h : e₁ ≲'(n) eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲'(n') eβ‚‚" }, { "name": "Env.Approx.Indexed'.delayed", "content": "lemma Env.Approx.Indexed'.delayed {n i : Nat} {env₁ envβ‚‚ env e}\n (h₁ : env₁ ≲ₑ'(n) envβ‚‚)\n (hβ‚‚ : env₁[i]? = some (Object.delayed env e)) :\n (βˆƒ env' e', e ≲(n)⟨env, env'⟩ e' ∧ envβ‚‚[i]? = some (Object.delayed env' e')) ∨\n βˆƒ env', env ≲ₑ'(n) env' ∧ envβ‚‚[i]? = some (Object.delayed env' e)" }, { "name": "Env.Approx.Indexed'.value", "content": "lemma Env.Approx.Indexed'.value {n i : Nat} {env env' v}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some (Object.value v)) :\n βˆƒ v', env'[i]? = some (Object.value v') ∧ v ≲α΅₯(n) v'" }, { "name": "Env.Approx.Indexed'.get", "content": "lemma Env.Approx.Indexed'.get {n i : Nat} {env env' o₁}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some o₁) :\n βˆƒ oβ‚‚, env'[i]? = some oβ‚‚ ∧ o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Value.Approx.Indexed.anti_monotone", "content": "lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚" }, { "name": "Value.Approx.Indexed.Preservation.anti_monotone", "content": "lemma Value.Approx.Indexed.Preservation.anti_monotone {k k'} (h : Value.Approx.Indexed.Preservation k) (h' : k' ≀ k) : Value.Approx.Indexed.Preservation k'" }, { "name": "Env.Approx.Indexed'.anti_monotone", "content": "lemma Env.Approx.Indexed'.anti_monotone {n n' env₁ envβ‚‚}\n (h : env₁ ≲ₑ'(n) envβ‚‚)\n (h' : n' ≀ n)\n : env₁ ≲ₑ'(n') envβ‚‚" }, { "name": "Object.Approx.Indexed'.anti_monotone", "content": "lemma Object.Approx.Indexed'.anti_monotone {n n' o₁ oβ‚‚} (h : o₁ ≲ₒ'(n) oβ‚‚) (h' : n' ≀ n) : o₁ ≲ₒ'(n') oβ‚‚" }, { "name": "Env.Approx.Indexed'.cons", "content": "lemma Env.Approx.Indexed'.cons {n o₁ oβ‚‚ env₁ envβ‚‚}\n (h₁ : o₁ ≲ₒ'(n) oβ‚‚)\n (hβ‚‚ : env₁ ≲ₑ'(n) envβ‚‚) :\n o₁ :: env₁ ≲ₑ'(n) oβ‚‚ :: envβ‚‚" }, { "name": "Env.Approx.Indexed'.concat", "content": "lemma Env.Approx.Indexed'.concat {n env₁ envβ‚‚ env₁' envβ‚‚'}\n (h₁ : env₁ ≲ₑ'(n) env₁')\n (hβ‚‚ : envβ‚‚ ≲ₑ'(n) envβ‚‚') :\n env₁ ++ envβ‚‚ ≲ₑ'(n) env₁' ++ envβ‚‚'" }, { "name": "Env.Approx.Indexed'.from_value", "content": "lemma Env.Approx.Indexed'.from_value {n l₁ lβ‚‚} (h : l₁ ≲ₐ(n) lβ‚‚) :\n List.map Object.value l₁ ≲ₑ'(n) List.map Object.value lβ‚‚" }, { "name": "Eval.deterministic", "content": "theorem Eval.deterministic {env e v₁ vβ‚‚} (h₁ : env ⊒ e ↦ v₁) (hβ‚‚ : env ⊒ e ↦ vβ‚‚) : v₁ = vβ‚‚" }, { "name": "Eval.toIndexed", "content": "lemma Eval.toIndexed {env e v} (h : env ⊒ e ↦ v) : βˆƒ n, env ⊒ e ↦(n) v" }, { "name": "Eval.Indexed.monotone", "content": "lemma Eval.Indexed.monotone {n n' env e v} (h : env ⊒ e ↦(n) v) (h' : n ≀ n') : env ⊒ e ↦(n') v" } ]
[ { "name": "Juvix.Core.Main.Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Juvix.Core.Main.Expr.Approx.Param", "content": "def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)" }, { "name": "Juvix.Core.Main.Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Juvix.Core.Main.Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "Juvix.Core.Main.Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" } ]
[ { "name": "Juvix.Core.Main.Env.Approx.cons", "content": "lemma Env.Approx.cons {env₁ envβ‚‚ o₁ oβ‚‚} :\n o₁ ≲ₒ oβ‚‚ β†’ env₁ ≲ₑ envβ‚‚ β†’ (o₁ :: env₁) ≲ₑ (oβ‚‚ :: envβ‚‚)" }, { "name": "Juvix.Core.Main.Object.Approx.toIndexed", "content": "lemma Object.Approx.toIndexed {o₁ oβ‚‚} : o₁ ≲ₒ oβ‚‚ β†’ βˆ€ n, o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.toIndexed", "content": "lemma Env.Approx.toIndexed {env₁ envβ‚‚} : env₁ ≲ₑ envβ‚‚ β†’ βˆ€ n, env₁ ≲ₑ'(n) envβ‚‚" } ]
import Juvix.Core.Main.Semantics.Approx.Indexed namespace Juvix.Core.Main def Value.Approx (v v' : Value) : Prop := βˆ€ n, v ≲α΅₯(n) v' notation:40 v:40 " ≲α΅₯ " v':40 => Value.Approx v v' notation:40 args₁:40 " ≲ₐ " argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚ def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚) notation:40 e:40 " β‰²βŸ¨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param env env' e e' inductive Object.Approx : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ Object.Approx notation:40 v:40 " ≲ₒ " v':40 => Object.Approx v v' notation:40 env₁:40 " ≲ₑ " envβ‚‚:40 => Env.Approx env₁ envβ‚‚ def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop := βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ notation:40 e₁:40 " ≲ " eβ‚‚:40 => Expr.Approx e₁ eβ‚‚
theorem Value.Approx.preserved : βˆ€ env env' e v, env ≲ₑ env' β†’ env ⊒ e ↦ v β†’ βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯ v' :=
:= by intro env env' e v h₁ hβ‚‚ suffices βˆ€ n, βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(n) v' by obtain ⟨v', heval', happrox'⟩ := this 0 exists v' constructor Β· assumption Β· intro n obtain ⟨v'', heval'', happrox''⟩ := this n have : v' = v'' := by apply Eval.deterministic <;> assumption subst this exact happrox'' intro m obtain ⟨n, hβ‚‚'⟩ := Eval.toIndexed hβ‚‚ have h₁' : env ≲ₑ'(m + n) env' := by apply Env.Approx.toIndexed assumption obtain ⟨v', heval', happrox'⟩ := Value.Approx.Indexed.preserved (env := env) (env' := env') m n e v h₁' hβ‚‚' aesop
4
66
false
Semantics
256
Juvix.Core.Main.Env.Approx.Indexed'.delayed
lemma Env.Approx.Indexed'.delayed {n i : Nat} {env₁ envβ‚‚ env e} (h₁ : env₁ ≲ₑ'(n) envβ‚‚) (hβ‚‚ : env₁[i]? = some (Object.delayed env e)) : (βˆƒ env' e', e ≲(n)⟨env, env'⟩ e' ∧ envβ‚‚[i]? = some (Object.delayed env' e')) ∨ βˆƒ env', env ≲ₑ'(n) env' ∧ envβ‚‚[i]? = some (Object.delayed env' e)
juvix-lean
Juvix/Core/Main/Semantics/Approx/Indexed.lean
[ "import Juvix.Utils", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Mathlib.Tactic.Linarith", "import Mathlib.Data.List.Forall2", "import Juvix.Core.Main.Semantics.Eval", "import Aesop" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" } ]
[ { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "List.Forallβ‚‚.get", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.Forallβ‚‚.length_eq", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.getElem?_eq_some_iff", "module": "Init.Data.List.Lemmas" }, { "name": "List.get_eq_getElem", "module": "Init.Data.List.Lemmas" }, { "name": "forall_true_left", "module": "Mathlib.Logic.Basic" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Juvix.Core.Main.Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" } ]
[ { "name": "Juvix.Core.Main.Env.Approx.Indexed'.get", "content": "lemma Env.Approx.Indexed'.get {n i : Nat} {env env' o₁}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some o₁) :\n βˆƒ oβ‚‚, env'[i]? = some oβ‚‚ ∧ o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.value", "content": "lemma Env.Approx.Indexed'.value {n i : Nat} {env env' v}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some (Object.value v)) :\n βˆƒ v', env'[i]? = some (Object.value v') ∧ v ≲α΅₯(n) v'" } ]
import Juvix.Core.Main.Semantics.Eval import Juvix.Core.Main.Semantics.Eval.Indexed import Juvix.Utils import Mathlib.Tactic.Linarith import Mathlib.Data.List.Forall2 import Aesop namespace Juvix.Core.Main notation:40 v:40 " ≲α΅₯(" n:40 ") " v':40 => Value.Approx.Indexed n v v' notation:40 args₁:40 " ≲ₐ(" n:40 ") " argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚ notation:40 e:40 " ≲(" n:40 ")⟨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param.Indexed n env env' e e' inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯(n) vβ‚‚ β†’ Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) | delayed_eq {env₁ envβ‚‚ e} : List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e) def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ (Object.Approx.Indexed' n) notation:40 v:40 " ≲ₒ'(" n:40 ") " v':40 => Object.Approx.Indexed' n v v' notation:40 env₁:40 " ≲ₑ'(" n:40 ") " envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚ notation:40 e:40 " ≲'(" n:40 ") " e':40 => Expr.Approx.Indexed' n e e'
lemma Env.Approx.Indexed'.delayed {n i : Nat} {env₁ envβ‚‚ env e} (h₁ : env₁ ≲ₑ'(n) envβ‚‚) (hβ‚‚ : env₁[i]? = some (Object.delayed env e)) : (βˆƒ env' e', e ≲(n)⟨env, env'⟩ e' ∧ envβ‚‚[i]? = some (Object.delayed env' e')) ∨ βˆƒ env', env ≲ₑ'(n) env' ∧ envβ‚‚[i]? = some (Object.delayed env' e) :=
:= by obtain ⟨o, h, happrox⟩ := Env.Approx.Indexed'.get h₁ hβ‚‚ cases h₃ : o case value v => rw [h₃] at happrox contradiction case delayed env' e' => rw [h₃] at happrox cases happrox case delayed h => left subst h₃ exists env' exists e' case delayed_eq => right subst h₃ exists env'
3
15
false
Semantics
257
Juvix.Core.Main.Value.Approx.Indexed.preserved'
lemma Value.Approx.Indexed.preserved' {k} : Preservation k
juvix-lean
Juvix/Core/Main/Semantics/Approx/Indexed.lean
[ "import Juvix.Utils", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Mathlib.Tactic.Linarith", "import Mathlib.Data.List.Forall2", "import Juvix.Core.Main.Semantics.Eval", "import Aesop" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.cons", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.nil", "module": "Batteries.Data.List.Basic" }, { "name": "List.cons", "module": "Init.Prelude" }, { "name": "List.nil", "module": "Init.Prelude" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "reduceCtorEq", "module": "Lean.Meta.Tactic.Simp.BuiltinSimprocs.Core" }, { "name": "List.map", "module": "Init.Prelude" } ]
[ { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚\n\nsyntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr" }, { "name": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Index", "content": "notation:40 e:40 \" ≲'(\" n:40 \") \" e':40 => Expr.Approx.Indexed' n e e'" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))\n\nsyntax \"let \" ident \" := \" expr \" in \" expr : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Expr.Approx.Param", "content": "def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)" }, { "name": "Eval.Indexed", "content": "inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where\n | var {n env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval.Indexed n env (Expr.var name idx) val\n | var_rec {n env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval.Indexed n env' expr val β†’\n Eval.Indexed n env (Expr.var name idx) val\n | unit {n env} :\n Eval.Indexed n env Expr.unit Value.unit\n | const {n env c} :\n Eval.Indexed n env (Expr.const c) (Value.const c)\n | constr {n env name} :\n Eval.Indexed n env (Expr.constr name) (Value.constr_app name [])\n | app {n n₁ nβ‚‚ env env' f body arg val val'} :\n n₁ + nβ‚‚ + 1 ≀ n β†’\n Eval.Indexed n₁ env f (Value.closure env' body) β†’\n Eval.Indexed (n₁ + 1) env arg val β†’\n Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’\n Eval.Indexed n env (Expr.app f arg) val'\n | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} :\n n' < n β†’\n Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval.Indexed n' env arg val β†’\n Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {n env name body} :\n Eval.Indexed n env (Expr.lambda name body) (Value.closure env body)\n | save {n n₁ nβ‚‚ env name value body val val'} :\n n₁ + nβ‚‚ ≀ n β†’\n Eval.Indexed n₁ env value val β†’\n Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’\n Eval.Indexed n env (Expr.save name value body) val'\n | branch_matches {n n' env name args_rev body val} :\n n' < n β†’\n Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {n env name name' args_rev next val} :\n name β‰  name' β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {n n' env name body val} :\n n' < n β†’\n Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval.Indexed n env (Expr.recur name body) val" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "Context", "content": "inductive Context : Type where\n | hole : Context\n | app_left : Context β†’ Expr β†’ Context\n | app_right : Expr β†’ Context β†’ Context\n | constr_app_left : Context β†’ Expr β†’ Context\n | constr_app_right : Expr β†’ Context β†’ Context\n | binop_left : (oper : BinaryOp) β†’ (arg₁ : Context) β†’ (argβ‚‚ : Expr) β†’ Context\n | binop_right : (oper : BinaryOp) β†’ (arg₁ : Expr) β†’ (argβ‚‚ : Context) β†’ Context\n | lambda : (var_name : String) β†’ (body : Context) β†’ Context\n | save_left : (var_name : String) β†’ (value : Context) β†’ (body : Expr) β†’ Context\n | save_right : (var_name : String) β†’ (value : Expr) β†’ (body : Context) β†’ Context\n | branch_left : (constr : Name) β†’ (var_names : List Name) β†’ (body : Context) β†’ (next : Expr) β†’ Context\n | branch_right : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Context) β†’ Context\n | recur : (var_name : Name) β†’ (ctx : Context) β†’ Context\n deriving Inhabited, BEq" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "and_self", "module": "Init.SimpLemmas" }, { "name": "exists_and_left", "module": "Init.PropLemmas" }, { "name": "exists_const", "module": "Init.PropLemmas" }, { "name": "exists_eq_left'", "module": "Init.PropLemmas" }, { "name": "false_and", "module": "Init.SimpLemmas" }, { "name": "false_or", "module": "Init.SimpLemmas" }, { "name": "implies_true", "module": "Init.SimpLemmas" }, { "name": "or_false", "module": "Init.SimpLemmas" }, { "name": "true_and", "module": "Init.SimpLemmas" }, { "name": "List.forallβ‚‚_same", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.Forallβ‚‚.get", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.Forallβ‚‚.length_eq", "module": "Mathlib.Data.List.Forall2" }, { "name": "List.getElem?_eq_some_iff", "module": "Init.Data.List.Lemmas" }, { "name": "List.get_eq_getElem", "module": "Init.Data.List.Lemmas" }, { "name": "forall_true_left", "module": "Mathlib.Logic.Basic" }, { "name": "Nat.le_eq", "module": "Init.Data.Nat.Basic" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" }, { "name": "Juvix.Core.Main.Expr.Approx.Param.Indexed", "content": "def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Juvix.Core.Main.Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" }, { "name": "Juvix.Core.Main.Expr.Approx.Indexed'", "content": "def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚)" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where\n | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit\n | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.Preservation", "content": "def Value.Approx.Indexed.Preservation (k : Nat) : Prop :=\n βˆ€ m n env env' e v,\n m + n < k β†’\n env ≲ₑ'(m + n) env' β†’\n env ⊒ e ↦(n) v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'" } ]
[ { "name": "Juvix.Core.Main.Env.Approx.Indexed'.get", "content": "lemma Env.Approx.Indexed'.get {n i : Nat} {env env' o₁}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some o₁) :\n βˆƒ oβ‚‚, env'[i]? = some oβ‚‚ ∧ o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.value", "content": "lemma Env.Approx.Indexed'.value {n i : Nat} {env env' v}\n (h₁ : env ≲ₑ'(n) env')\n (hβ‚‚ : env[i]? = some (Object.value v)) :\n βˆƒ v', env'[i]? = some (Object.value v') ∧ v ≲α΅₯(n) v'" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.delayed", "content": "lemma Env.Approx.Indexed'.delayed {n i : Nat} {env₁ envβ‚‚ env e}\n (h₁ : env₁ ≲ₑ'(n) envβ‚‚)\n (hβ‚‚ : env₁[i]? = some (Object.delayed env e)) :\n (βˆƒ env' e', e ≲(n)⟨env, env'⟩ e' ∧ envβ‚‚[i]? = some (Object.delayed env' e')) ∨\n βˆƒ env', env ≲ₑ'(n) env' ∧ envβ‚‚[i]? = some (Object.delayed env' e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.from_value", "content": "lemma Env.Approx.Indexed'.from_value {n l₁ lβ‚‚} (h : l₁ ≲ₐ(n) lβ‚‚) :\n List.map Object.value l₁ ≲ₑ'(n) List.map Object.value lβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.concat", "content": "lemma Env.Approx.Indexed'.concat {n env₁ envβ‚‚ env₁' envβ‚‚'}\n (h₁ : env₁ ≲ₑ'(n) env₁')\n (hβ‚‚ : envβ‚‚ ≲ₑ'(n) envβ‚‚') :\n env₁ ++ envβ‚‚ ≲ₑ'(n) env₁' ++ envβ‚‚'" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.cons", "content": "lemma Env.Approx.Indexed'.cons {n o₁ oβ‚‚ env₁ envβ‚‚}\n (h₁ : o₁ ≲ₒ'(n) oβ‚‚)\n (hβ‚‚ : env₁ ≲ₑ'(n) envβ‚‚) :\n o₁ :: env₁ ≲ₑ'(n) oβ‚‚ :: envβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.anti_monotone", "content": "lemma Value.Approx.Indexed.anti_monotone {n n' v₁ vβ‚‚} (h : v₁ ≲α΅₯(n) vβ‚‚) (h' : n' ≀ n) : v₁ ≲α΅₯(n') vβ‚‚" }, { "name": "Juvix.Core.Main.Expr.Approx.Param.Indexed.anti_monotone", "content": "lemma Expr.Approx.Param.Indexed.anti_monotone {n n' env₁ envβ‚‚ e₁ eβ‚‚}\n (h : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲(n')⟨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Juvix.Core.Main.Expr.Approx.Indexed'.anti_monotone", "content": "lemma Expr.Approx.Indexed'.anti_monotone {n n' e₁ eβ‚‚}\n (h : e₁ ≲'(n) eβ‚‚)\n (h' : n' ≀ n)\n : e₁ ≲'(n') eβ‚‚" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'.anti_monotone", "content": " lemma Env.Approx.Indexed'.anti_monotone {n n' env₁ envβ‚‚}\n (h : env₁ ≲ₑ'(n) envβ‚‚)\n (h' : n' ≀ n)\n : env₁ ≲ₑ'(n') envβ‚‚" }, { "name": "Juvix.Core.Main.Object.Approx.Indexed'.anti_monotone", "content": " lemma Object.Approx.Indexed'.anti_monotone {n n' o₁ oβ‚‚} (h : o₁ ≲ₒ'(n) oβ‚‚) (h' : n' ≀ n) : o₁ ≲ₒ'(n') oβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.Preservation.anti_monotone", "content": "lemma Value.Approx.Indexed.Preservation.anti_monotone {k k'} (h : Value.Approx.Indexed.Preservation k) (h' : k' ≀ k) : Value.Approx.Indexed.Preservation k'" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.preserved_step", "content": "lemma Value.Approx.Indexed.preserved_step {k} :\n (βˆ€ k' < k, Preservation k') β†’ Preservation k" } ]
import Juvix.Core.Main.Semantics.Eval import Juvix.Core.Main.Semantics.Eval.Indexed import Juvix.Utils import Mathlib.Tactic.Linarith import Mathlib.Data.List.Forall2 import Aesop namespace Juvix.Core.Main def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop := (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨ (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨ (βˆƒ ctr_name args_rev args_rev', v₁ = Value.constr_app ctr_name args_rev ∧ vβ‚‚ = Value.constr_app ctr_name args_rev' ∧ (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨ (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚, v₁ = Value.closure env₁ body₁ ∧ vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧ (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’ βˆ€ a₁ aβ‚‚ r₁, Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’ a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’ βˆƒ rβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧ Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚)) notation:40 v:40 " ≲α΅₯(" n:40 ") " v':40 => Value.Approx.Indexed n v v' notation:40 args₁:40 " ≲ₐ(" n:40 ") " argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚ def Expr.Approx.Param.Indexed (n : Nat) (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) notation:40 e:40 " ≲(" n:40 ")⟨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param.Indexed n env env' e e' inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯(n) vβ‚‚ β†’ Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) | delayed_eq {env₁ envβ‚‚ e} : List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e) def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ (Object.Approx.Indexed' n) notation:40 v:40 " ≲ₒ'(" n:40 ") " v':40 => Object.Approx.Indexed' n v v' notation:40 env₁:40 " ≲ₑ'(" n:40 ") " envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚ def Expr.Approx.Indexed' (n : Nat) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ n₁ nβ‚‚ v₁, n₁ + nβ‚‚ ≀ n β†’ βˆ€ env₁ envβ‚‚, env₁ ≲ₑ'(n₁ + nβ‚‚) envβ‚‚ β†’ env₁ ⊒ e₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) notation:40 e:40 " ≲'(" n:40 ") " e':40 => Expr.Approx.Indexed' n e e' @[aesop safe cases] inductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c) | constr_app {ctr_name args_rev args_rev'} : (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’ Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev') | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} : (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’ βˆ€ a₁ aβ‚‚ v₁, a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’ a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’ βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’ Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚) end def Value.Approx.Indexed.Preservation (k : Nat) : Prop := βˆ€ m n env env' e v, m + n < k β†’ env ≲ₑ'(m + n) env' β†’ env ⊒ e ↦(n) v β†’ βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯(m) v'
lemma Value.Approx.Indexed.preserved' {k} : Preservation k :=
:= by suffices βˆ€ k' ≀ k, Preservation k' by aesop induction k with | zero => intro k' hk' refine preserved_step ?_ intro k hk linarith | succ k ih => intro k' hk' cases hk' case succ.refl => refine preserved_step ?_ intro k' hk' apply ih linarith case succ.step => apply ih simp_all only [Nat.le_eq]
9
80
false
Semantics
258
Juvix.Core.Main.Object.Approx.Indexed'.refl'
lemma Object.Approx.Indexed'.refl' {n o} (h : βˆ€ v, v ≲α΅₯(n) v) : o ≲ₒ'(n) o
juvix-lean
Juvix/Core/Main/Semantics/Approx/Indexed.lean
[ "import Juvix.Utils", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Mathlib.Tactic.Linarith", "import Mathlib.Data.List.Forall2", "import Juvix.Core.Main.Semantics.Eval", "import Aesop" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.cons", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.nil", "module": "Batteries.Data.List.Basic" }, { "name": "List.cons", "module": "Init.Prelude" }, { "name": "List.nil", "module": "Init.Prelude" } ]
[ { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Juvix.Core.Main.Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" } ]
[ { "name": "Juvix.Core.Main.Env.Approx.Indexed'.refl'", "content": " lemma Env.Approx.Indexed'.refl' {n env} (h : βˆ€ v, v ≲α΅₯(n) v) : env ≲ₑ'(n) env" } ]
import Juvix.Core.Main.Semantics.Eval import Juvix.Core.Main.Semantics.Eval.Indexed import Juvix.Utils import Mathlib.Tactic.Linarith import Mathlib.Data.List.Forall2 import Aesop namespace Juvix.Core.Main notation:40 v:40 " ≲α΅₯(" n:40 ") " v':40 => Value.Approx.Indexed n v v' notation:40 args₁:40 " ≲ₐ(" n:40 ") " argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚ notation:40 e:40 " ≲(" n:40 ")⟨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param.Indexed n env env' e e' inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯(n) vβ‚‚ β†’ Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) | delayed_eq {env₁ envβ‚‚ e} : List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e) def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ (Object.Approx.Indexed' n) notation:40 v:40 " ≲ₒ'(" n:40 ") " v':40 => Object.Approx.Indexed' n v v' notation:40 env₁:40 " ≲ₑ'(" n:40 ") " envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚ notation:40 e:40 " ≲'(" n:40 ") " e':40 => Expr.Approx.Indexed' n e e' end
lemma Object.Approx.Indexed'.refl' {n o} (h : βˆ€ v, v ≲α΅₯(n) v) : o ≲ₒ'(n) o :=
:= by cases o case value v => apply Object.Approx.Indexed'.value apply h case delayed env e => apply Object.Approx.Indexed'.delayed_eq exact Env.Approx.Indexed'.refl' h
3
14
false
Semantics
259
Juvix.Core.Main.Expr.Equiv.eval_const
lemma Expr.Equiv.eval_const {op a₁ aβ‚‚ i₁ iβ‚‚ i₃} : a₁ β‰ˆ Expr.const (Constant.int i₁) β†’ aβ‚‚ β‰ˆ Expr.const (Constant.int iβ‚‚) β†’ i₃ = eval_binop_int op i₁ iβ‚‚ β†’ Expr.binop op a₁ aβ‚‚ β‰ˆ Expr.const (Constant.int i₃)
juvix-lean
Juvix/Core/Main/Semantics/Equiv.lean
[ "import Juvix.Core.Main.Semantics.Approx" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "List", "module": "Init.Prelude" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" } ]
[ { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'\n\nsyntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))" }, { "name": "notation:40 e₁:40 \" β‰ˆ \" eβ‚‚:40 => Expr.Equiv e₁ eβ‚‚", "content": "notation:40 e₁:40 \" β‰ˆ \" eβ‚‚:40 => Expr.Equiv e₁ eβ‚‚" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" }, { "name": "Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Eval.Indexed", "content": "inductive Eval.Indexed : Nat β†’ Env β†’ Expr β†’ Value β†’ Prop where\n | var {n env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval.Indexed n env (Expr.var name idx) val\n | var_rec {n env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval.Indexed n env' expr val β†’\n Eval.Indexed n env (Expr.var name idx) val\n | unit {n env} :\n Eval.Indexed n env Expr.unit Value.unit\n | const {n env c} :\n Eval.Indexed n env (Expr.const c) (Value.const c)\n | constr {n env name} :\n Eval.Indexed n env (Expr.constr name) (Value.constr_app name [])\n | app {n n₁ nβ‚‚ env env' f body arg val val'} :\n n₁ + nβ‚‚ + 1 ≀ n β†’\n Eval.Indexed n₁ env f (Value.closure env' body) β†’\n Eval.Indexed (n₁ + 1) env arg val β†’\n Eval.Indexed nβ‚‚ (val ∷ env') body val' β†’\n Eval.Indexed n env (Expr.app f arg) val'\n | constr_app {n n' env ctr ctr_name ctr_args_rev arg val} :\n n' < n β†’\n Eval.Indexed n env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval.Indexed n' env arg val β†’\n Eval.Indexed n env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {n env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval.Indexed n env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval.Indexed n env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval.Indexed n env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {n env name body} :\n Eval.Indexed n env (Expr.lambda name body) (Value.closure env body)\n | save {n n₁ nβ‚‚ env name value body val val'} :\n n₁ + nβ‚‚ ≀ n β†’\n Eval.Indexed n₁ env value val β†’\n Eval.Indexed nβ‚‚ (val ∷ env) body val' β†’\n Eval.Indexed n env (Expr.save name value body) val'\n | branch_matches {n n' env name args_rev body val} :\n n' < n β†’\n Eval.Indexed n' (args_rev.map Object.value ++ env) body val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {n env name name' args_rev next val} :\n name β‰  name' β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) next val β†’\n Eval.Indexed n (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {n n' env name body val} :\n n' < n β†’\n Eval.Indexed n' (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval.Indexed n env (Expr.recur name body) val" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "Expr.Approx.eval_const₁", "content": "lemma Expr.Approx.eval_const₁ {op a₁ aβ‚‚ i₁ iβ‚‚ i₃} :\n a₁ ≲ Expr.const (Constant.int i₁) β†’\n aβ‚‚ ≲ Expr.const (Constant.int iβ‚‚) β†’\n i₃ = eval_binop_int op i₁ iβ‚‚ β†’\n Expr.binop op a₁ aβ‚‚ ≲\n Expr.const (Constant.int i₃)" }, { "name": "Expr.Approx.const_right", "content": "lemma Expr.Approx.const_right {c e env v} :\n e ≲ Expr.const c β†’\n env ⊒ e ↦ v β†’\n v = Value.const c" }, { "name": "Expr.Approx.preservation", "content": "lemma Expr.Approx.preservation {e₁ eβ‚‚} :\n e₁ ≲ eβ‚‚ ↔\n βˆ€ env v₁, env ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, env ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚" }, { "name": "Expr.Approx.to_preservation", "content": "lemma Expr.Approx.to_preservation {e₁ eβ‚‚} :\n e₁ ≲ eβ‚‚ β†’\n βˆ€ env v₁, env ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, env ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚" }, { "name": "Expr.Approx.from_preservation", "content": "lemma Expr.Approx.from_preservation {e₁ eβ‚‚}\n (h : βˆ€ env v₁, env ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, env ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)\n : e₁ ≲ eβ‚‚" }, { "name": "Value.Approx.preserved", "content": "theorem Value.Approx.preserved :\n βˆ€ env env' e v,\n env ≲ₑ env' β†’\n env ⊒ e ↦ v β†’\n βˆƒ v', env' ⊒ e ↦ v' ∧ v ≲α΅₯ v'" }, { "name": "Env.Approx.toIndexed", "content": "lemma Env.Approx.toIndexed {env₁ envβ‚‚} : env₁ ≲ₑ envβ‚‚ β†’ βˆ€ n, env₁ ≲ₑ'(n) envβ‚‚" }, { "name": "Object.Approx.toIndexed", "content": "lemma Object.Approx.toIndexed {o₁ oβ‚‚} : o₁ ≲ₒ oβ‚‚ β†’ βˆ€ n, o₁ ≲ₒ'(n) oβ‚‚" }, { "name": "Env.Approx.cons", "content": "lemma Env.Approx.cons {env₁ envβ‚‚ o₁ oβ‚‚} :\n o₁ ≲ₒ oβ‚‚ β†’ env₁ ≲ₑ envβ‚‚ β†’ (o₁ :: env₁) ≲ₑ (oβ‚‚ :: envβ‚‚)" }, { "name": "Expr.Approx.eval_constβ‚‚", "content": "lemma Expr.Approx.eval_constβ‚‚ {op a₁ aβ‚‚ i₁ iβ‚‚ i₃} :\n Expr.const (Constant.int i₁) ≲ a₁ β†’\n Expr.const (Constant.int iβ‚‚) ≲ aβ‚‚ β†’\n i₃ = eval_binop_int op i₁ iβ‚‚ β†’\n Expr.const (Constant.int i₃) ≲\n Expr.binop op a₁ aβ‚‚" }, { "name": "Expr.Approx.const_left", "content": "lemma Expr.Approx.const_left {c e env} :\n Expr.const c ≲ e β†’\n env ⊒ e ↦ Value.const c" }, { "name": "Expr.Approx.const", "content": "lemma Expr.Approx.const {c₁ cβ‚‚} :\n Expr.const c₁ ≲ Expr.const cβ‚‚ β†’\n c₁ = cβ‚‚" } ]
[ { "name": "Juvix.Core.Main.Expr.Equiv", "content": "def Expr.Equiv (e₁ eβ‚‚ : Expr) : Prop :=\n e₁ ≲ eβ‚‚ ∧ eβ‚‚ ≲ e₁" } ]
[]
import Juvix.Core.Main.Semantics.Approx namespace Juvix.Core.Main notation:40 v:40 " β‰ˆα΅₯ " v':40 => Value.Equiv v v' notation:40 args₁:40 " β‰ˆβ‚ " argsβ‚‚:40 => List.Forallβ‚‚ Value.Equiv args₁ argsβ‚‚ notation:40 v:40 " β‰ˆβ‚’ " v':40 => Object.Equiv v v' notation:40 env₁:40 " β‰ˆβ‚‘ " envβ‚‚:40 => Env.Equiv env₁ envβ‚‚ notation:40 e₁:40 " β‰ˆβŸ¨" env₁:40 ", " envβ‚‚:40 "⟩ " eβ‚‚:40 => Expr.Equiv.Param env₁ envβ‚‚ e₁ eβ‚‚ def Expr.Equiv (e₁ eβ‚‚ : Expr) : Prop := e₁ ≲ eβ‚‚ ∧ eβ‚‚ ≲ e₁ notation:40 e₁:40 " β‰ˆ " eβ‚‚:40 => Expr.Equiv e₁ eβ‚‚
lemma Expr.Equiv.eval_const {op a₁ aβ‚‚ i₁ iβ‚‚ i₃} : a₁ β‰ˆ Expr.const (Constant.int i₁) β†’ aβ‚‚ β‰ˆ Expr.const (Constant.int iβ‚‚) β†’ i₃ = eval_binop_int op i₁ iβ‚‚ β†’ Expr.binop op a₁ aβ‚‚ β‰ˆ Expr.const (Constant.int i₃) :=
:= by simp only [Expr.Equiv] intro h₁ hβ‚‚ h₃ constructor Β· apply Expr.Approx.eval_const₁ (op := op) (i₁ := i₁) (iβ‚‚ := iβ‚‚) <;> simp_all only Β· apply Expr.Approx.eval_constβ‚‚ (op := op) (i₁ := i₁) (iβ‚‚ := iβ‚‚) <;> simp_all only
3
40
false
Semantics
260
Juvix.Core.Main.Env.Approx.Indexed'.from_delayed
lemma Env.Approx.Indexed'.from_delayed {n env₁ envβ‚‚ l} (h : env₁ ≲ₑ'(n) envβ‚‚) : List.map (Object.delayed env₁) l ≲ₑ'(n) List.map (Object.delayed envβ‚‚) l
juvix-lean
Juvix/Core/Main/Semantics/Approx/Indexed.lean
[ "import Juvix.Utils", "import Juvix.Core.Main.Semantics.Eval.Indexed", "import Mathlib.Tactic.Linarith", "import Mathlib.Data.List.Forall2", "import Juvix.Core.Main.Semantics.Eval", "import Aesop" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "List.map", "module": "Init.Prelude" }, { "name": "List.Forallβ‚‚.cons", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.nil", "module": "Batteries.Data.List.Basic" } ]
[ { "name": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e'", "content": "notation:40 e:40 \" ≲(\" n:40 \")⟨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param.Indexed n env env' e e'" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.In", "content": "notation:40 v:40 \" ≲ₒ'(\" n:40 \") \" v':40 => Object.Approx.Indexed' n v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.", "content": "notation:40 env₁:40 \" ≲ₑ'(\" n:40 \") \" envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Juvix.Core.Main.Object.Approx.Indexed'", "content": "inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} :\n v₁ ≲α΅₯(n) vβ‚‚ β†’\n Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)\n | delayed_eq {env₁ envβ‚‚ e} :\n List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’\n Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e)" }, { "name": "Juvix.Core.Main.Env.Approx.Indexed'", "content": "def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ (Object.Approx.Indexed' n)" } ]
[]
import Juvix.Core.Main.Semantics.Eval import Juvix.Core.Main.Semantics.Eval.Indexed import Juvix.Utils import Mathlib.Tactic.Linarith import Mathlib.Data.List.Forall2 import Aesop namespace Juvix.Core.Main notation:40 v:40 " ≲α΅₯(" n:40 ") " v':40 => Value.Approx.Indexed n v v' notation:40 args₁:40 " ≲ₐ(" n:40 ") " argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚ notation:40 e:40 " ≲(" n:40 ")⟨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param.Indexed n env env' e e' inductive Object.Approx.Indexed' (n : Nat) : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯(n) vβ‚‚ β†’ Object.Approx.Indexed' n (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ ≲(n)⟨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) | delayed_eq {env₁ envβ‚‚ e} : List.Forallβ‚‚ (Object.Approx.Indexed' n) env₁ envβ‚‚ β†’ Object.Approx.Indexed' n (Object.delayed env₁ e) (Object.delayed envβ‚‚ e) def Env.Approx.Indexed' (n : Nat) : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ (Object.Approx.Indexed' n) notation:40 v:40 " ≲ₒ'(" n:40 ") " v':40 => Object.Approx.Indexed' n v v' notation:40 env₁:40 " ≲ₑ'(" n:40 ") " envβ‚‚:40 => Env.Approx.Indexed' n env₁ envβ‚‚ notation:40 e:40 " ≲'(" n:40 ") " e':40 => Expr.Approx.Indexed' n e e'
lemma Env.Approx.Indexed'.from_delayed {n env₁ envβ‚‚ l} (h : env₁ ≲ₑ'(n) envβ‚‚) : List.map (Object.delayed env₁) l ≲ₑ'(n) List.map (Object.delayed envβ‚‚) l :=
:= by induction l case nil => exact List.Forallβ‚‚.nil case cons e l' h' => simp apply List.Forallβ‚‚.cons Β· apply Object.Approx.Indexed'.delayed_eq assumption Β· assumption
3
12
false
Semantics
261
Juvix.Core.Main.Termination.binop
lemma Termination.binop {env op e₁ eβ‚‚ c₁ cβ‚‚} : env ⊒ e₁ ↦ Value.const (Constant.int c₁) β†’ env ⊒ eβ‚‚ ↦ Value.const (Constant.int cβ‚‚) β†’ env ⊒ Expr.binop op e₁ eβ‚‚ ↓
juvix-lean
Juvix/Core/Main/Tactics/Termination.lean
[ "import Juvix.Core.Main.Tactics.Base" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" } ]
[ { "name": "syntax:100 expr:100 ppSpace expr:101 : expr", "content": "syntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[]
import Juvix.Core.Main.Tactics.Base namespace Juvix.Core.Main
lemma Termination.binop {env op e₁ eβ‚‚ c₁ cβ‚‚} : env ⊒ e₁ ↦ Value.const (Constant.int c₁) β†’ env ⊒ eβ‚‚ ↦ Value.const (Constant.int cβ‚‚) β†’ env ⊒ Expr.binop op e₁ eβ‚‚ ↓ :=
:= by intro h₁ hβ‚‚ constructor apply Juvix.Core.Main.Eval.binop Β· assumption Β· assumption
4
18
false
Semantics
262
Juvix.Core.Main.Object.Approx.trans
@[trans] lemma Object.Approx.trans {o₁ oβ‚‚ o₃} : o₁ ≲ₒ oβ‚‚ β†’ oβ‚‚ ≲ₒ o₃ β†’ o₁ ≲ₒ o₃
juvix-lean
Juvix/Core/Main/Semantics/Approx.lean
[ "import Juvix.Core.Main.Semantics.Approx.Indexed", "import Juvix.Utils" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "IsEmpty", "module": "Mathlib.Logic.IsEmpty" } ]
[ { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.A", "content": "notation:40 args₁:40 \" ≲ₐ \" argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚" }, { "name": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).inve", "content": "macro \"invert\" h:term : tactic => `(tactic| (cases ($h).invert <;> try clear $h))" }, { "name": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Foral", "content": "notation:40 args₁:40 \" ≲ₐ(\" n:40 \") \" argsβ‚‚:40 => List.Forallβ‚‚ (Value.Approx.Indexed n) args₁ argsβ‚‚\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "Env", "content": "abbrev Env : Type := List Object\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Value.Approx.Indexed", "content": "def Value.Approx.Indexed (n : Nat) (v₁ vβ‚‚ : Value) : Prop :=\n (v₁ = Value.unit ∧ vβ‚‚ = Value.unit) ∨\n (βˆƒ c, v₁ = Value.const c ∧ vβ‚‚ = Value.const c) ∨\n (βˆƒ ctr_name args_rev args_rev',\n v₁ = Value.constr_app ctr_name args_rev ∧\n vβ‚‚ = Value.constr_app ctr_name args_rev' ∧\n (βˆ€ k < n, List.Forallβ‚‚ (Value.Approx.Indexed k) args_rev args_rev')) ∨\n (βˆƒ env₁ body₁ envβ‚‚ bodyβ‚‚,\n v₁ = Value.closure env₁ body₁ ∧\n vβ‚‚ = Value.closure envβ‚‚ bodyβ‚‚ ∧\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ r₁,\n Value.Approx.Indexed (n₁ + nβ‚‚) a₁ aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) r₁ β†’\n βˆƒ rβ‚‚,\n aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ rβ‚‚ ∧\n Value.Approx.Indexed nβ‚‚ r₁ rβ‚‚))" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env" }, { "name": "Value.Approx.Indexed.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Indexed.Inversion (n : Nat) : Value β†’ Value β†’ Prop where\n | unit : Value.Approx.Indexed.Inversion n Value.unit Value.unit\n | const {c} : Value.Approx.Indexed.Inversion n (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.Approx.Indexed.Inversion n (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.Approx.Indexed.Inversion n (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "IsEmpty.forall_iff", "module": "Mathlib.Logic.IsEmpty" }, { "name": "implies_true", "module": "Init.SimpLemmas" }, { "name": "nonpos_iff_eq_zero", "module": "Mathlib.Algebra.Order.Monoid.Canonical.Defs" }, { "name": "not_lt_zero'", "module": "Mathlib.Algebra.Order.GroupWithZero.Canonical" } ]
[ { "name": "Value.Approx.Indexed.invert", "content": "@[aesop unsafe destruct]\nlemma Value.Approx.Indexed.invert {n v v'} :\n v ≲α΅₯(n) v' β†’\n Value.Approx.Indexed.Inversion n v v'" }, { "name": "Value.Approx.Indexed.constr_app", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.constr_app {n ctr_name args_rev args_rev'} :\n (βˆ€ k < n, args_rev ≲ₐ(k) args_rev') β†’\n Value.constr_app ctr_name args_rev ≲α΅₯(n) Value.constr_app ctr_name args_rev'" }, { "name": "Value.Approx.Indexed.unit", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.unit {n} : Value.unit ≲α΅₯(n) Value.unit" }, { "name": "Value.Approx.Indexed.const", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.const {n c} : Value.const c ≲α΅₯(n) Value.const c" }, { "name": "Value.Approx.Indexed.closure", "content": "@[aesop unsafe apply]\nlemma Value.Approx.Indexed.closure {n env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ n₁ nβ‚‚, n₁ + nβ‚‚ < n β†’\n βˆ€ a₁ aβ‚‚ v₁,\n a₁ ≲α΅₯(n₁ + nβ‚‚) aβ‚‚ β†’\n a₁ ∷ env₁ ⊒ body₁ ↦(n₁) v₁ β†’\n βˆƒ vβ‚‚, aβ‚‚ ∷ envβ‚‚ ⊒ bodyβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯(nβ‚‚) vβ‚‚) β†’\n Value.closure env₁ body₁ ≲α΅₯(n) Value.closure envβ‚‚ bodyβ‚‚" }, { "name": "forallβ‚‚_trans'", "content": "theorem forallβ‚‚_trans' {Ξ±} {P Q R : Ξ± β†’ Ξ± β†’ Prop} {l₁ lβ‚‚ l₃}\n (h : βˆ€ x y z, P x y β†’ Q y z β†’ R x z)\n (h₁ : List.Forallβ‚‚ P l₁ lβ‚‚)\n (hβ‚‚ : List.Forallβ‚‚ Q lβ‚‚ l₃)\n : List.Forallβ‚‚ R l₁ l₃" } ]
[ { "name": "Juvix.Core.Main.Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Juvix.Core.Main.Expr.Approx.Param", "content": "def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop :=\n (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚)" }, { "name": "Juvix.Core.Main.Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Juvix.Core.Main.Expr.Approx", "content": "def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop :=\n βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚" }, { "name": "Juvix.Core.Main.Value.Approx.Inversion", "content": "@[aesop safe cases]\ninductive Value.Approx.Inversion : Value -> Value -> Prop where\n | unit : Value.Approx.Inversion Value.unit Value.unit\n | const {c} : Value.Approx.Inversion (Value.const c) (Value.const c)\n | constr_app {ctr_name args_rev args_rev'} :\n args_rev ≲ₐ args_rev' β†’\n Value.Approx.Inversion (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev')\n | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} :\n (βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’\n Value.Approx.Inversion (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.invert", "content": "@[aesop unsafe destruct]\nlemma Value.Approx.invert {v v'} :\n v ≲α΅₯ v' β†’\n Value.Approx.Inversion v v'" }, { "name": "Juvix.Core.Main.Value.Approx.Indexed.trans", "content": "@[trans]\nlemma Value.Approx.Indexed.trans {n v₁ vβ‚‚ v₃} : v₁ ≲α΅₯(n) vβ‚‚ β†’ vβ‚‚ ≲α΅₯ v₃ β†’ v₁ ≲α΅₯(n) v₃" }, { "name": "Juvix.Core.Main.Value.Approx.trans", "content": "@[trans]\nlemma Value.Approx.trans {v₁ vβ‚‚ v₃} : v₁ ≲α΅₯ vβ‚‚ β†’ vβ‚‚ ≲α΅₯ v₃ β†’ v₁ ≲α΅₯ v₃" }, { "name": "Juvix.Core.Main.Expr.Approx.Param.trans", "content": "lemma Expr.Approx.Param.trans {env₁ envβ‚‚ env₃ e₁ eβ‚‚ e₃} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’ eβ‚‚ β‰²βŸ¨envβ‚‚, envβ‚ƒβŸ© e₃ β†’ e₁ β‰²βŸ¨env₁, envβ‚ƒβŸ© e₃" } ]
import Juvix.Core.Main.Semantics.Approx.Indexed namespace Juvix.Core.Main def Value.Approx (v v' : Value) : Prop := βˆ€ n, v ≲α΅₯(n) v' notation:40 v:40 " ≲α΅₯ " v':40 => Value.Approx v v' notation:40 args₁:40 " ≲ₐ " argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚ def Expr.Approx.Param (env₁ envβ‚‚ : Env) (e₁ eβ‚‚ : Expr) : Prop := (βˆ€ v₁, env₁ ⊒ e₁ ↦ v₁ β†’ βˆƒ vβ‚‚, envβ‚‚ ⊒ eβ‚‚ ↦ vβ‚‚ ∧ v₁ ≲α΅₯ vβ‚‚) notation:40 e:40 " β‰²βŸ¨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param env env' e e' inductive Object.Approx : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) notation:40 v:40 " ≲ₒ " v':40 => Object.Approx v v' notation:40 env₁:40 " ≲ₑ " envβ‚‚:40 => Env.Approx env₁ envβ‚‚ def Expr.Approx (e₁ eβ‚‚ : Expr) : Prop := βˆ€ env₁ envβ‚‚, env₁ ≲ₑ envβ‚‚ β†’ e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ notation:40 e₁:40 " ≲ " eβ‚‚:40 => Expr.Approx e₁ eβ‚‚ @[aesop safe cases] inductive Value.Approx.Inversion : Value -> Value -> Prop where | unit : Value.Approx.Inversion Value.unit Value.unit | const {c} : Value.Approx.Inversion (Value.const c) (Value.const c) | constr_app {ctr_name args_rev args_rev'} : args_rev ≲ₐ args_rev' β†’ Value.Approx.Inversion (Value.constr_app ctr_name args_rev) (Value.constr_app ctr_name args_rev') | closure {env₁ body₁ envβ‚‚ bodyβ‚‚} : (βˆ€ a₁ aβ‚‚, a₁ ≲α΅₯ aβ‚‚ β†’ body₁ β‰²βŸ¨a₁ ∷ env₁, aβ‚‚ ∷ envβ‚‚βŸ© bodyβ‚‚) β†’ Value.Approx.Inversion (Value.closure env₁ body₁) (Value.closure envβ‚‚ bodyβ‚‚)
@[trans] lemma Object.Approx.trans {o₁ oβ‚‚ o₃} : o₁ ≲ₒ oβ‚‚ β†’ oβ‚‚ ≲ₒ o₃ β†’ o₁ ≲ₒ o₃ :=
:= by intros h₁ hβ‚‚ cases h₁ case value v₁ vβ‚‚ happrox => cases hβ‚‚ case value v₃ happrox' => apply Object.Approx.value trans vβ‚‚ <;> assumption case delayed env₁ envβ‚‚ e₁ eβ‚‚ happrox => cases hβ‚‚ case delayed envβ‚‚' eβ‚‚' happrox' => apply Object.Approx.delayed exact Expr.Approx.Param.trans happrox happrox'
6
39
false
Semantics
263
Juvix.Core.Main.Env.Approx.cons_value
lemma Env.Approx.cons_value {v₁ vβ‚‚ env} : v₁ ≲α΅₯ vβ‚‚ β†’ v₁ ∷ env ≲ₑ vβ‚‚ ∷ env
juvix-lean
Juvix/Core/Main/Semantics/Approx.lean
[ "import Juvix.Core.Main.Semantics.Approx.Indexed" ]
[ { "name": "List", "module": "Init.Prelude" }, { "name": "List.Forallβ‚‚", "module": "Batteries.Data.List.Basic" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" }, { "name": "List.Forallβ‚‚.cons", "module": "Batteries.Data.List.Basic" }, { "name": "List.Forallβ‚‚.nil", "module": "Batteries.Data.List.Basic" } ]
[ { "name": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Exp", "content": "notation:40 e:40 \" β‰²βŸ¨\" env:40 \", \" env':40 \"⟩ \" e':40 => Expr.Approx.Param env env' e e'" }, { "name": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'", "content": "notation:40 v:40 \" ≲α΅₯ \" v':40 => Value.Approx v v'" }, { "name": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚", "content": "notation:40 e₁:40 \" ≲ \" eβ‚‚:40 => Expr.Approx e₁ eβ‚‚" }, { "name": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Inde", "content": "notation:40 v:40 \" ≲α΅₯(\" n:40 \") \" v':40 => Value.Approx.Indexed n v v'\n\nsyntax \"case \" expr \" of \" cases \" end\" : expr" }, { "name": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'", "content": "notation:40 v:40 \" ≲ₒ \" v':40 => Object.Approx v v'" }, { "name": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚", "content": "notation:40 env₁:40 \" ≲ₑ \" envβ‚‚:40 => Env.Approx env₁ envβ‚‚" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Juvix.Core.Main.Value.Approx", "content": "def Value.Approx (v v' : Value) : Prop :=\n βˆ€ n, v ≲α΅₯(n) v'" }, { "name": "Juvix.Core.Main.Object.Approx", "content": "inductive Object.Approx : Object β†’ Object β†’ Prop where\n | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚)\n | delayed {env₁ envβ‚‚ e₁ eβ‚‚} :\n e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’\n Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚)" }, { "name": "Juvix.Core.Main.Env.Approx", "content": "def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop :=\n List.Forallβ‚‚ Object.Approx" } ]
[ { "name": "Juvix.Core.Main.Value.Approx.refl", "content": "@[refl]\nlemma Value.Approx.refl v : v ≲α΅₯ v" }, { "name": "Juvix.Core.Main.Object.Approx.refl", "content": "@[refl]\nlemma Object.Approx.refl {o} : o ≲ₒ o" }, { "name": "Juvix.Core.Main.Env.Approx.refl", "content": "@[refl]\nlemma Env.Approx.refl {env} : env ≲ₑ env" }, { "name": "Juvix.Core.Main.Env.Approx.cons", "content": "lemma Env.Approx.cons {env₁ envβ‚‚ o₁ oβ‚‚} :\n o₁ ≲ₒ oβ‚‚ β†’ env₁ ≲ₑ envβ‚‚ β†’ (o₁ :: env₁) ≲ₑ (oβ‚‚ :: envβ‚‚)" } ]
import Juvix.Core.Main.Semantics.Approx.Indexed namespace Juvix.Core.Main def Value.Approx (v v' : Value) : Prop := βˆ€ n, v ≲α΅₯(n) v' notation:40 v:40 " ≲α΅₯ " v':40 => Value.Approx v v' notation:40 args₁:40 " ≲ₐ " argsβ‚‚:40 => List.Forallβ‚‚ Value.Approx args₁ argsβ‚‚ notation:40 e:40 " β‰²βŸ¨" env:40 ", " env':40 "⟩ " e':40 => Expr.Approx.Param env env' e e' inductive Object.Approx : Object β†’ Object β†’ Prop where | value {v₁ vβ‚‚} : v₁ ≲α΅₯ vβ‚‚ β†’ Object.Approx (Object.value v₁) (Object.value vβ‚‚) | delayed {env₁ envβ‚‚ e₁ eβ‚‚} : e₁ β‰²βŸ¨env₁, envβ‚‚βŸ© eβ‚‚ β†’ Object.Approx (Object.delayed env₁ e₁) (Object.delayed envβ‚‚ eβ‚‚) def Env.Approx : (env₁ envβ‚‚ : Env) β†’ Prop := List.Forallβ‚‚ Object.Approx notation:40 v:40 " ≲ₒ " v':40 => Object.Approx v v' notation:40 env₁:40 " ≲ₑ " envβ‚‚:40 => Env.Approx env₁ envβ‚‚ notation:40 e₁:40 " ≲ " eβ‚‚:40 => Expr.Approx e₁ eβ‚‚
lemma Env.Approx.cons_value {v₁ vβ‚‚ env} : v₁ ≲α΅₯ vβ‚‚ β†’ v₁ ∷ env ≲ₑ vβ‚‚ ∷ env :=
:= by intro h apply Env.Approx.cons Β· apply Object.Approx.value assumption Β· apply Env.Approx.refl
4
26
false
Semantics
264
Juvix.Core.Main.Termination.branch_matches
lemma Termination.branch_matches {env name vnames args_rev e e'} : args_rev.map Object.value ++ env ⊒ e ↓ β†’ Value.constr_app name args_rev ∷ env ⊒ Expr.branch name vnames e e' ↓
juvix-lean
Juvix/Core/Main/Tactics/Termination.lean
[ "import Juvix.Core.Main.Tactics.Base" ]
[ { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "closure", "module": "Mathlib.Topology.Defs.Basic" } ]
[ { "name": "syntax:100 expr:100 ppSpace expr:101 : expr", "content": "syntax:100 expr:100 ppSpace expr:101 : expr\n\nsyntax:50 expr:50 \" + \" expr:51 : expr\n\nsyntax:50 expr:50 \" - \" expr:50 : expr\n\nsyntax:60 expr:60 \" * \" expr:61 : expr\n\nsyntax:60 expr:60 \" / \" expr:60 : expr" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↓\" => Eval.Defined env e" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Inde", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦(\" n \") \" v:40 => Eval.Indexed n env e v" }, { "name": "macro_rules", "content": "macro_rules\n | `(βŸͺ$s:ident β™― $i:num⟫) => `(Expr.var $(Lean.Syntax.mkStrLit s.getId.toString) $i)\n | `(βŸͺ$num:num⟫) => `(Expr.const (Constant.int $num))\n | `(βŸͺ$s:str⟫) => `(Expr.const (Constant.string $s))\n | `(βŸͺΟ…βŸ«) => `(Expr.unit)\n | `(βŸͺ$e₁:expr $eβ‚‚:expr⟫) => `(Expr.app βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺΞ» $s:ident $e:expr⟫) => `(Expr.lambda $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$e⟫)\n | `(βŸͺΞ» $ss:ident* . $e:expr⟫) => mkLambdas ss e\n | `(βŸͺ $s:ident ⟫) => `(Expr.constr $(Lean.Syntax.mkStrLit s.getId.toString))\n | `(βŸͺ $s:ident $es:expr* ⟫) => mkConstrApp s es\n | `(βŸͺ$e₁ + $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.add_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ - $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.sub_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ * $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.mul_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺ$e₁ / $eβ‚‚βŸ«) => `(Expr.binop BinaryOp.div_int βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺlet $s:ident := $e₁:expr in $eβ‚‚:expr⟫) => `(Expr.save $(Lean.Syntax.mkStrLit s.getId.toString) βŸͺ$eβ‚βŸ« βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺletrec $s:ident := $e₁:expr in $eβ‚‚:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.save $name (Expr.recur $name βŸͺ$eβ‚βŸ«) βŸͺ$eβ‚‚βŸ«)\n | `(βŸͺrec $s:ident $e:expr⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.recur $name βŸͺ$e⟫)\n | `(βŸͺβŠ₯⟫) => `(Expr.fail)\n | `(βŸͺcases| | $s:ident => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr $cs:cases ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺcases| | $s:ident => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n `(Expr.branch $name [] βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | $s:ident $ss:ident* => $e:expr ⟫) =>\n let name := Lean.Syntax.mkStrLit s.getId.toString\n let vnames := ss.toList.map fun s => s.getId.toString\n `(Expr.branch $name $(quote vnames) βŸͺ$e⟫ Expr.fail)\n | `(βŸͺcases| | _ => $e:expr ⟫) =>\n `(βŸͺ$e⟫)\n | `(βŸͺcase $e:expr of $cs:cases end⟫) => do\n `(Expr.save \"_case_\" βŸͺ$e⟫ βŸͺcases|$cs⟫)\n | `(βŸͺ($e)⟫) => `(βŸͺ$e⟫)" }, { "name": "Eval", "content": "@[aesop unsafe constructors]\ninductive Eval : Env β†’ Expr β†’ Value β†’ Prop where\n | var {env name idx val} :\n env[idx]? = some (Object.value val) β†’\n Eval env (Expr.var name idx) val\n | var_rec {env name idx env' expr val} :\n env[idx]? = some (Object.delayed env' expr) β†’\n Eval env' expr val β†’\n Eval env (Expr.var name idx) val\n | unit {env} :\n Eval env Expr.unit Value.unit\n | const {env c} :\n Eval env (Expr.const c) (Value.const c)\n | constr {env name} :\n Eval env (Expr.constr name) (Value.constr_app name [])\n | app {env env' f body arg val val'} :\n Eval env f (Value.closure env' body) β†’\n Eval env arg val β†’\n Eval (val ∷ env') body val' β†’\n Eval env (Expr.app f arg) val'\n | constr_app {env ctr ctr_name ctr_args_rev arg val} :\n Eval env ctr (Value.constr_app ctr_name ctr_args_rev) β†’\n Eval env arg val β†’\n Eval env (Expr.constr_app ctr arg) (Value.constr_app ctr_name (val :: ctr_args_rev))\n | binop {env op arg₁ argβ‚‚ val₁ valβ‚‚} :\n Eval env arg₁ (Value.const (Constant.int val₁)) β†’\n Eval env argβ‚‚ (Value.const (Constant.int valβ‚‚)) β†’\n Eval env (Expr.binop op arg₁ argβ‚‚) (Value.const (Constant.int (eval_binop_int op val₁ valβ‚‚)))\n | lambda {env name body} :\n Eval env (Expr.lambda name body) (Value.closure env body)\n | save {env name value body val val'} :\n Eval env value val β†’\n Eval (val ∷ env) body val' β†’\n Eval env (Expr.save name value body) val'\n | branch_matches {env name args_rev body val} :\n Eval (args_rev.map Object.value ++ env) body val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name _ body _) val\n | branch_fails {env name name' args_rev next val} :\n name β‰  name' β†’\n Eval (Value.constr_app name args_rev ∷ env) next val β†’\n Eval (Value.constr_app name args_rev ∷ env) (Expr.branch name' _ _ next) val\n | recur {env name body val} :\n Eval (Object.delayed env (Expr.recur name body) :: env) body val β†’\n Eval env (Expr.recur name body) val" }, { "name": "eval_binop_int", "content": "def eval_binop_int (op : BinaryOp) (i₁ iβ‚‚ : Int) : Int :=\n match op with\n | BinaryOp.add_int => i₁ + iβ‚‚\n | BinaryOp.sub_int => i₁ - iβ‚‚\n | BinaryOp.mul_int => i₁ * iβ‚‚\n | BinaryOp.div_int => i₁ / iβ‚‚" }, { "name": "BinaryOp", "content": "inductive BinaryOp : Type where\n | add_int : BinaryOp\n | sub_int : BinaryOp\n | mul_int : BinaryOp\n | div_int : BinaryOp\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Expr", "content": "inductive Expr : Type where\n | var : (name : String) β†’ (index : Nat) β†’ Expr\n | unit : Expr\n | const : Constant β†’ Expr\n | constr : Name β†’ Expr\n | app : Expr β†’ Expr β†’ Expr\n | constr_app : Expr β†’ Expr β†’ Expr\n | binop : (oper : BinaryOp) β†’ (arg₁ argβ‚‚ : Expr) β†’ Expr\n | lambda : (var_name : String) β†’ (body : Expr) β†’ Expr\n | save : (var_name : String) β†’ (value : Expr) β†’ (body : Expr) β†’ Expr\n | branch : (constr : Name) β†’ (var_names : List Name) β†’ (body : Expr) β†’ (next : Expr) β†’ Expr\n | recur : (var_name : Name) β†’ (body : Expr) β†’ Expr\n | fail : Expr\n deriving Inhabited, BEq, DecidableEq" }, { "name": "cons_value", "content": "abbrev cons_value (v : Value) (env : Env) : Env := Object.value v :: env\n\n inductive Object : Type where\n | value : Value β†’ Object\n | delayed : (env : List Object) β†’ Expr β†’ Object\n deriving Inhabited\n\n inductive Value : Type where\n | unit : Value\n | const : Constant β†’ Value\n | constr_app : (constr : Name) β†’ (args_rev : List Value) β†’ Value\n | closure : (env : List Object) β†’ (value : Expr) β†’ Value\n deriving Inhabited" }, { "name": "Constant", "content": "inductive Constant : Type where\n | int : Int β†’ Constant\n | string : String β†’ Constant\n deriving Inhabited, BEq, DecidableEq" }, { "name": "Name", "content": "abbrev Name : Type := String" }, { "name": "Env", "content": "abbrev Env : Type := List Object" }, { "name": "infixr:50 \" ∷ \" => cons_value", "content": "infixr:50 \" ∷ \" => cons_value" }, { "name": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v", "content": "notation:40 env:40 \" ⊒ \" e:40 \" ↦ \" v:40 => Eval env e v" }, { "name": "infixl:100 \" @@ \" => Expr.app", "content": "infixl:100 \" @@ \" => Expr.app" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[]
import Juvix.Core.Main.Tactics.Base namespace Juvix.Core.Main
lemma Termination.branch_matches {env name vnames args_rev e e'} : args_rev.map Object.value ++ env ⊒ e ↓ β†’ Value.constr_app name args_rev ∷ env ⊒ Expr.branch name vnames e e' ↓ :=
:= by intro h obtain ⟨w, h⟩ := h constructor apply Juvix.Core.Main.Eval.branch_matches assumption
4
18
false
Semantics
265
eval_bool_completeness
theorem eval_bool_completeness (e: BoolExpr V): BoolStepStar V val e (BoolExpr.Const (eval_bool V val e))
LeanExprEvaluator
ExprEval/Basic.lean
[ "import ExprEval.Steps", "import ExprEval.Lemmas", "import ExprEval.Expr" ]
[ { "name": "And", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Eq", "module": "Init.Prelude" }, { "name": "Not", "module": "Init.Prelude" }, { "name": "Or", "module": "Init.Prelude" }, { "name": "Add", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "Mul", "module": "Init.Prelude" }, { "name": "Sub", "module": "Init.Prelude" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "ite", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Computation", "module": "Mathlib.Data.Seq.Computation" }, { "name": "Max", "module": "Init.Prelude" }, { "name": "Max.max", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" } ]
[ { "name": "BoolStepStar", "content": "def BoolStepStar (V: Type) := StepStar (Step := BoolStep V) V" }, { "name": "BoolStep", "content": "inductive BoolStep: (val: V -> Int) -> (BoolExpr V) -> (BoolExpr V) -> Prop where\n | notIsBoolNot (b: Bool): BoolStep val\n (BoolExpr.Not (BoolExpr.Const b))\n (BoolExpr.Const !b)\n | andLeftTrue (e: BoolExpr V): BoolStep val\n (BoolExpr.And (BoolExpr.Const true) e)\n e\n | orLeftFalse (e: BoolExpr V): BoolStep val\n (BoolExpr.Or (BoolExpr.Const false) e)\n e\n | andLeftShortCircuit e : BoolStep val\n (BoolExpr.And (BoolExpr.Const false) e)\n (BoolExpr.Const false)\n | orLeftShortCircuit e : BoolStep val\n (BoolExpr.Or (BoolExpr.Const true) e)\n (BoolExpr.Const true)\n | lessConstConstTrue n₁ nβ‚‚ : n₁ < nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | lessConstConstFalse n₁ nβ‚‚ : n₁ >= nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | eqConstConstTrue n₁ nβ‚‚ : n₁ = nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | eqConstConstFalse n₁ nβ‚‚ : n₁ != nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | lessArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁' eβ‚‚)\n | eqArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁' eβ‚‚)\n | lessArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁ eβ‚‚')\n | eqArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁ eβ‚‚')\n | orStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Or e₁ eβ‚‚)\n (BoolExpr.Or e₁' eβ‚‚)\n | andStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.And e₁ eβ‚‚)\n (BoolExpr.And e₁' eβ‚‚)\n | notStep (e e' : BoolExpr V):\n BoolStep val e e' -> BoolStep val\n (BoolExpr.Not e)\n (BoolExpr.Not e')" }, { "name": "ArStep", "content": "inductive ArStep: (val: V -> Int) -> (ArExpr V) -> (ArExpr V) -> Prop where\n | getVarValue (var: V) :\n ArStep\n val\n (ArExpr.Var var)\n (ArExpr.Const (val var))\n | addConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Add (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ + nβ‚‚))\n | subConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Sub (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ - nβ‚‚))\n | mulConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Mul (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ * nβ‚‚))\n | addLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Add e₁ eβ‚‚) (ArExpr.Add e₁' eβ‚‚)\n\n | subLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Sub e₁ eβ‚‚) (ArExpr.Sub e₁' eβ‚‚)\n\n | mulLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Mul e₁ eβ‚‚) (ArExpr.Mul e₁' eβ‚‚)\n\n | addRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Add (ArExpr.Const n) eβ‚‚) (ArExpr.Add (ArExpr.Const n) eβ‚‚')\n\n | subRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Sub (ArExpr.Const n) eβ‚‚) (ArExpr.Sub (ArExpr.Const n) eβ‚‚')\n | mulRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Mul (ArExpr.Const n) eβ‚‚) (ArExpr.Mul (ArExpr.Const n) eβ‚‚')\n\n | ifStep (e e': BoolExpr V) (a b : ArExpr V): BoolStep val e e' ->\n ArStep val (ArExpr.If e a b) (ArExpr.If e' a b)\n | ifCondTrue (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const true) a b) a\n | ifCondFalse (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const false) a b) b\n\n inductive ArExpr: Type\n | Const: Int -> ArExpr\n | Add: ArExpr -> ArExpr -> ArExpr\n | Sub: ArExpr -> ArExpr -> ArExpr\n | Mul: ArExpr -> ArExpr -> ArExpr\n | Var: V -> ArExpr\n | If : BoolExpr -> ArExpr -> ArExpr -> ArExpr\n\n inductive BoolExpr : Type\n | Const: Bool -> BoolExpr\n | Less: ArExpr -> ArExpr -> BoolExpr\n | Eq: ArExpr -> ArExpr -> BoolExpr\n | Not : BoolExpr -> BoolExpr\n | And : BoolExpr -> BoolExpr -> BoolExpr\n | Or : BoolExpr -> BoolExpr -> BoolExpr" }, { "name": "StepStar", "content": "inductive StepStar {ExprType: Type} {Step: StepKind V ExprType} : (val: V -> Int) -> ExprType -> ExprType -> Prop where\n | refl val e : StepStar val e e\n | trans e₁ eβ‚‚ e₃ : Step val e₁ eβ‚‚ -> StepStar val eβ‚‚ e₃ -> StepStar val e₁ e₃" }, { "name": "BoolStepStar.refl", "content": "def BoolStepStar.refl {V: Type} (val: V -> Int) := StepStar.refl (Step := BoolStep V) val\n\n def eval (val: V -> Int) (e: ArExpr V) : Int :=\n match e with\n | ArExpr.Const x => x\n | ArExpr.Add lhs rhs => (eval val lhs) + (eval val rhs)\n | ArExpr.Sub lhs rhs => (eval val lhs) - (eval val rhs)\n | ArExpr.Mul lhs rhs => (eval val lhs) * (eval val rhs)\n | ArExpr.Var v => val v\n | ArExpr.If cond then_e else_e => if eval_bool val cond then eval val then_e else eval val else_e\n\n def eval_bool (val: V -> Int) (e: BoolExpr V): Bool :=\n match e with\n | BoolExpr.Const b => b\n | BoolExpr.Less l r => (eval val l) < (eval val r)\n | BoolExpr.Eq l r => (eval val l) == (eval val r)\n | BoolExpr.Not e => not (eval_bool val e)\n | BoolExpr.And l r => if eval_bool val l then eval_bool val r else false\n | BoolExpr.Or l r => if eval_bool val l then true else eval_bool val r" }, { "name": "ArStepStar.trans", "content": "def ArStepStar.trans {V: Type} {val: V -> Int} e₁ eβ‚‚ e₃ := StepStar.trans e₁ eβ‚‚ e₃ (Step := ArStep V) (val := val)" }, { "name": "ArStepStar", "content": "def ArStepStar (V: Type) := StepStar (Step := ArStep V) V" }, { "name": "ArStepStar.refl", "content": "def ArStepStar.refl {V: Type} (val: V -> Int) := StepStar.refl (Step := ArStep V) val" }, { "name": "BoolStepStar.trans", "content": "def BoolStepStar.trans {V: Type} {val: V -> Int} e₁ eβ‚‚ e₃ := StepStar.trans e₁ eβ‚‚ e₃ (Step := BoolStep V) (val := val)" }, { "name": "StepKind", "content": "def StepKind (V: Type) (ExprType: Type):= (V -> Int) -> ExprType -> ExprType -> Prop" } ]
[ { "name": "Int.not_lt", "module": "Init.Data.Int.Order" }, { "name": "bne_iff_ne", "module": "Init.SimpLemmas" }, { "name": "decide_eq_false", "module": "Init.Prelude" }, { "name": "decide_eq_true", "module": "Init.Prelude" }, { "name": "eq_false_of_ne_true", "module": "Init.Prelude" }, { "name": "ge_iff_le", "module": "Init.Core" }, { "name": "ne_of_beq_false", "module": "Init.Core" } ]
[ { "name": "BoolStepStar.andStepLeft", "content": "theorem BoolStepStar.andStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStepStar V val e₁ e₁' -> BoolStepStar V val\n (BoolExpr.And e₁ eβ‚‚)\n (BoolExpr.And e₁' eβ‚‚)" }, { "name": "chasles_step_star", "content": "theorem chasles_step_star {ExprKind: Type} {Step: StepKind V ExprKind} {e₁ eβ‚‚ e₃: ExprKind}:\n StepStar (Step := Step) V val e₁ eβ‚‚ ->\n StepStar (Step := Step) V val eβ‚‚ e₃ ->\n StepStar (Step := Step) V val e₁ e₃" }, { "name": "BoolStepStar.lessArStepStarLeft", "content": "theorem BoolStepStar.lessArStepStarLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStepStar V val e₁ e₁' ->\n BoolStepStar V val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁' eβ‚‚)" }, { "name": "BoolStepStar.notStep", "content": "theorem BoolStepStar.notStep {V: Type} {val: V -> Int}\n (e e': BoolExpr V):\n BoolStepStar V val e e' -> BoolStepStar V val (BoolExpr.Not e) (BoolExpr.Not e')" }, { "name": "BoolStepStar.lessArStepStarRight", "content": "theorem BoolStepStar.lessArStepStarRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n BoolStepStar V val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁ eβ‚‚')" }, { "name": "step_to_stepstar", "content": "theorem step_to_stepstar {ExprKind: Type} {Step: StepKind V ExprKind} {e e': ExprKind}:\n Step val e e' -> StepStar (Step := Step) V val e e'" }, { "name": "BoolStepStar.eqArStepStarRight", "content": "theorem BoolStepStar.eqArStepStarRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n BoolStepStar V val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁ eβ‚‚')" }, { "name": "BoolStepStar.eqArStepStarLeft", "content": "theorem BoolStepStar.eqArStepStarLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStepStar V val e₁ e₁' ->\n BoolStepStar V val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁' eβ‚‚)" }, { "name": "BoolStepStar.orStepLeft", "content": "theorem BoolStepStar.orStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStepStar V val e₁ e₁' -> BoolStepStar V val\n (BoolExpr.Or e₁ eβ‚‚)\n (BoolExpr.Or e₁' eβ‚‚)" }, { "name": "arstepstar_add_right", "content": "theorem arstepstar_add_right (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) :\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n ArStepStar V val\n (ArExpr.Add (ArExpr.Const n) eβ‚‚)\n (ArExpr.Add (ArExpr.Const n) eβ‚‚')" }, { "name": "arstepstar_sub_left", "content": "theorem arstepstar_sub_left (e₁ e₁' eβ‚‚: ArExpr V) :\n ArStepStar V val e₁ e₁' ->\n ArStepStar V val\n (ArExpr.Sub e₁ eβ‚‚)\n (ArExpr.Sub e₁' eβ‚‚)" }, { "name": "arstepstar_add_left", "content": "theorem arstepstar_add_left (e₁ e₁' eβ‚‚: ArExpr V) :\n ArStepStar V val e₁ e₁' -> ArStepStar V val (ArExpr.Add e₁ eβ‚‚) (ArExpr.Add e₁' eβ‚‚)" }, { "name": "arstepstar_sub_right", "content": "theorem arstepstar_sub_right (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) :\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n ArStepStar V val\n (ArExpr.Sub (ArExpr.Const n) eβ‚‚)\n (ArExpr.Sub (ArExpr.Const n) eβ‚‚')" }, { "name": "ArStepStar.ifStep", "content": "theorem ArStepStar.ifStep (e e': BoolExpr V) (a b: ArExpr V): BoolStepStar V val e e' ->\n ArStepStar V val (ArExpr.If e a b) (ArExpr.If e' a b)" }, { "name": "arstepstar_mul_right", "content": "theorem arstepstar_mul_right (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) :\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n ArStepStar V val\n (ArExpr.Mul (ArExpr.Const n) eβ‚‚)\n (ArExpr.Mul (ArExpr.Const n) eβ‚‚')" }, { "name": "arstepstar_mul_left", "content": "theorem arstepstar_mul_left (e₁ e₁' eβ‚‚: ArExpr V) :\n ArStepStar V val e₁ e₁' ->\n ArStepStar V val\n (ArExpr.Mul e₁ eβ‚‚)\n (ArExpr.Mul e₁' eβ‚‚)" } ]
[]
[ { "name": "eval_completeness", "content": " theorem eval_completeness (e: ArExpr V) : ArStepStar V val e (ArExpr.Const (eval V val e))" } ]
import ExprEval.Steps import ExprEval.Lemmas variable (V: Type)
theorem eval_bool_completeness (e: BoolExpr V): BoolStepStar V val e (BoolExpr.Const (eval_bool V val e)) :=
:= by cases e with | Const b => simp [eval_bool] apply BoolStepStar.refl | Not e => simp [eval_bool] have ihn := eval_bool_completeness e (val := val) have h := BoolStepStar.notStep e _ ihn have h1 := BoolStep.notIsBoolNot (eval_bool V val e) (val := val) have h2 := (step_to_stepstar V h1) apply chasles_step_star V h h2 | And l r => have l_step := eval_bool_completeness l (val := val) have r_step := eval_bool_completeness r (val := val) simp [eval_bool] by_cases h: (eval_bool V val l) . simp [and] rw [h] simp rw [h] at l_step have h1 := BoolStep.andLeftTrue r (val := val) have h2 := StepStar.trans _ _ _ h1 r_step have h3 := BoolStepStar.andStepLeft _ _ r l_step exact chasles_step_star V h3 h2 . replace h := eq_false_of_ne_true h rw [h] rw [h] at l_step simp [and] have h1 := BoolStepStar.andStepLeft _ _ r l_step have h2 := BoolStep.andLeftShortCircuit r (val := val) have h3 := step_to_stepstar V h2 exact chasles_step_star V h1 h3 | Or l r => have l_step := eval_bool_completeness l (val := val) have r_step := eval_bool_completeness r (val := val) simp [eval_bool] by_cases h: (eval_bool V val l) . rw [h] rw [h] at l_step simp [or] have h1 := BoolStepStar.orStepLeft _ _ r l_step have h2 := BoolStep.orLeftShortCircuit r (val := val) have h3 := step_to_stepstar V h2 exact chasles_step_star V h1 h3 . replace h := eq_false_of_ne_true h rw [h] rw [h] at l_step simp have h1 := BoolStep.orLeftFalse r (val := val) have h2 := StepStar.trans _ _ _ h1 r_step have h3 := BoolStepStar.orStepLeft _ _ r l_step exact chasles_step_star V h3 h2 | Eq l r => simp [eval_bool] by_cases h: (eval V val l == eval V val r) . replace h := eq_of_beq h rw [h] simp have h1 := BoolStep.eqConstConstTrue _ _ h (val := val) have hl := eval_completeness l (val := val) have hr := eval_completeness r (val := val) have h2 := BoolStepStar.eqArStepStarLeft l (ArExpr.Const (eval V val l)) r hl have h3 := BoolStepStar.eqArStepStarRight (ArExpr.Const (eval V val l)) r (ArExpr.Const (eval V val r)) hr have h4 := chasles_step_star V h2 h3 exact chasles_step_star V h4 (step_to_stepstar V h1) . replace h := eq_false_of_ne_true h rw [h] have h' := ne_of_beq_false h rw [<- bne_iff_ne] at h' have h1 := BoolStep.eqConstConstFalse _ _ h' (val := val) have hl := eval_completeness l (val := val) have hr := eval_completeness r (val := val) have h2 := BoolStepStar.eqArStepStarLeft l (ArExpr.Const (eval V val l)) r hl have h3 := BoolStepStar.eqArStepStarRight (ArExpr.Const (eval V val l)) r (ArExpr.Const (eval V val r)) hr have h4 := chasles_step_star V h2 h3 exact chasles_step_star V h4 (step_to_stepstar V h1) | Less l r => simp [eval_bool] by_cases h: (eval V val l < eval V val r) . rw [decide_eq_true] have h1 := BoolStep.lessConstConstTrue _ _ h (val := val) have hr := eval_completeness r (val := val) have hl := eval_completeness l (val := val) have hr := eval_completeness r (val := val) have h2 := BoolStepStar.lessArStepStarLeft l (ArExpr.Const (eval V val l)) r hl have h3 := BoolStepStar.lessArStepStarRight (ArExpr.Const (eval V val l)) r (ArExpr.Const (eval V val r)) hr have h4 := chasles_step_star V h2 h3 apply chasles_step_star V h4 (step_to_stepstar V h1) exact h . rw [decide_eq_false] have h' := h rw [Int.not_lt] at h' rw [<- ge_iff_le] at h' have h1 := BoolStep.lessConstConstFalse _ _ h' (val := val) have hl := eval_completeness l (val := val) have hr := eval_completeness r (val := val) have h2 := BoolStepStar.lessArStepStarLeft l (ArExpr.Const (eval V val l)) r hl have h3 := BoolStepStar.lessArStepStarRight (ArExpr.Const (eval V val l)) r (ArExpr.Const (eval V val r)) hr have h4 := chasles_step_star V h2 h3 exact chasles_step_star V h4 (step_to_stepstar V h1) exact h
4
60
true
Semantics
266
eval_completeness
theorem eval_completeness (e: ArExpr V) : ArStepStar V val e (ArExpr.Const (eval V val e))
LeanExprEvaluator
ExprEval/Basic.lean
[ "import ExprEval.Steps", "import ExprEval.Lemmas", "import ExprEval.Expr" ]
[ { "name": "Add", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "Mul", "module": "Init.Prelude" }, { "name": "Sub", "module": "Init.Prelude" }, { "name": "And", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Eq", "module": "Init.Prelude" }, { "name": "Not", "module": "Init.Prelude" }, { "name": "Or", "module": "Init.Prelude" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "ite", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Computation", "module": "Mathlib.Data.Seq.Computation" }, { "name": "Max", "module": "Init.Prelude" }, { "name": "Max.max", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" } ]
[ { "name": "ArStep", "content": "inductive ArStep: (val: V -> Int) -> (ArExpr V) -> (ArExpr V) -> Prop where\n | getVarValue (var: V) :\n ArStep\n val\n (ArExpr.Var var)\n (ArExpr.Const (val var))\n | addConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Add (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ + nβ‚‚))\n | subConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Sub (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ - nβ‚‚))\n | mulConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Mul (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ * nβ‚‚))\n | addLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Add e₁ eβ‚‚) (ArExpr.Add e₁' eβ‚‚)\n\n | subLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Sub e₁ eβ‚‚) (ArExpr.Sub e₁' eβ‚‚)\n\n | mulLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Mul e₁ eβ‚‚) (ArExpr.Mul e₁' eβ‚‚)\n\n | addRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Add (ArExpr.Const n) eβ‚‚) (ArExpr.Add (ArExpr.Const n) eβ‚‚')\n\n | subRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Sub (ArExpr.Const n) eβ‚‚) (ArExpr.Sub (ArExpr.Const n) eβ‚‚')\n | mulRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Mul (ArExpr.Const n) eβ‚‚) (ArExpr.Mul (ArExpr.Const n) eβ‚‚')\n\n | ifStep (e e': BoolExpr V) (a b : ArExpr V): BoolStep val e e' ->\n ArStep val (ArExpr.If e a b) (ArExpr.If e' a b)\n | ifCondTrue (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const true) a b) a\n | ifCondFalse (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const false) a b) b" }, { "name": "ArStepStar.trans", "content": "def ArStepStar.trans {V: Type} {val: V -> Int} e₁ eβ‚‚ e₃ := StepStar.trans e₁ eβ‚‚ e₃ (Step := ArStep V) (val := val)" }, { "name": "BoolStep", "content": "inductive BoolStep: (val: V -> Int) -> (BoolExpr V) -> (BoolExpr V) -> Prop where\n | notIsBoolNot (b: Bool): BoolStep val\n (BoolExpr.Not (BoolExpr.Const b))\n (BoolExpr.Const !b)\n | andLeftTrue (e: BoolExpr V): BoolStep val\n (BoolExpr.And (BoolExpr.Const true) e)\n e\n | orLeftFalse (e: BoolExpr V): BoolStep val\n (BoolExpr.Or (BoolExpr.Const false) e)\n e\n | andLeftShortCircuit e : BoolStep val\n (BoolExpr.And (BoolExpr.Const false) e)\n (BoolExpr.Const false)\n | orLeftShortCircuit e : BoolStep val\n (BoolExpr.Or (BoolExpr.Const true) e)\n (BoolExpr.Const true)\n | lessConstConstTrue n₁ nβ‚‚ : n₁ < nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | lessConstConstFalse n₁ nβ‚‚ : n₁ >= nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | eqConstConstTrue n₁ nβ‚‚ : n₁ = nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | eqConstConstFalse n₁ nβ‚‚ : n₁ != nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | lessArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁' eβ‚‚)\n | eqArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁' eβ‚‚)\n | lessArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁ eβ‚‚')\n | eqArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁ eβ‚‚')\n | orStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Or e₁ eβ‚‚)\n (BoolExpr.Or e₁' eβ‚‚)\n | andStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.And e₁ eβ‚‚)\n (BoolExpr.And e₁' eβ‚‚)\n | notStep (e e' : BoolExpr V):\n BoolStep val e e' -> BoolStep val\n (BoolExpr.Not e)\n (BoolExpr.Not e')\n\n inductive BoolExpr : Type\n | Const: Bool -> BoolExpr\n | Less: ArExpr -> ArExpr -> BoolExpr\n | Eq: ArExpr -> ArExpr -> BoolExpr\n | Not : BoolExpr -> BoolExpr\n | And : BoolExpr -> BoolExpr -> BoolExpr\n | Or : BoolExpr -> BoolExpr -> BoolExpr\n\n inductive ArExpr: Type\n | Const: Int -> ArExpr\n | Add: ArExpr -> ArExpr -> ArExpr\n | Sub: ArExpr -> ArExpr -> ArExpr\n | Mul: ArExpr -> ArExpr -> ArExpr\n | Var: V -> ArExpr\n | If : BoolExpr -> ArExpr -> ArExpr -> ArExpr" }, { "name": "StepStar", "content": "inductive StepStar {ExprType: Type} {Step: StepKind V ExprType} : (val: V -> Int) -> ExprType -> ExprType -> Prop where\n | refl val e : StepStar val e e\n | trans e₁ eβ‚‚ e₃ : Step val e₁ eβ‚‚ -> StepStar val eβ‚‚ e₃ -> StepStar val e₁ e₃" }, { "name": "ArStepStar", "content": "def ArStepStar (V: Type) := StepStar (Step := ArStep V) V\n\n def eval (val: V -> Int) (e: ArExpr V) : Int :=\n match e with\n | ArExpr.Const x => x\n | ArExpr.Add lhs rhs => (eval val lhs) + (eval val rhs)\n | ArExpr.Sub lhs rhs => (eval val lhs) - (eval val rhs)\n | ArExpr.Mul lhs rhs => (eval val lhs) * (eval val rhs)\n | ArExpr.Var v => val v\n | ArExpr.If cond then_e else_e => if eval_bool val cond then eval val then_e else eval val else_e\n\n def eval_bool (val: V -> Int) (e: BoolExpr V): Bool :=\n match e with\n | BoolExpr.Const b => b\n | BoolExpr.Less l r => (eval val l) < (eval val r)\n | BoolExpr.Eq l r => (eval val l) == (eval val r)\n | BoolExpr.Not e => not (eval_bool val e)\n | BoolExpr.And l r => if eval_bool val l then eval_bool val r else false\n | BoolExpr.Or l r => if eval_bool val l then true else eval_bool val r" }, { "name": "ArStepStar.refl", "content": "def ArStepStar.refl {V: Type} (val: V -> Int) := StepStar.refl (Step := ArStep V) val" }, { "name": "BoolStepStar", "content": "def BoolStepStar (V: Type) := StepStar (Step := BoolStep V) V" }, { "name": "BoolStepStar.refl", "content": "def BoolStepStar.refl {V: Type} (val: V -> Int) := StepStar.refl (Step := BoolStep V) val" }, { "name": "StepKind", "content": "def StepKind (V: Type) (ExprType: Type):= (V -> Int) -> ExprType -> ExprType -> Prop" }, { "name": "BoolStepStar.trans", "content": "def BoolStepStar.trans {V: Type} {val: V -> Int} e₁ eβ‚‚ e₃ := StepStar.trans e₁ eβ‚‚ e₃ (Step := BoolStep V) (val := val)" } ]
[ { "name": "Int.not_lt", "module": "Init.Data.Int.Order" }, { "name": "bne_iff_ne", "module": "Init.SimpLemmas" }, { "name": "decide_eq_false", "module": "Init.Prelude" }, { "name": "decide_eq_true", "module": "Init.Prelude" }, { "name": "eq_false_of_ne_true", "module": "Init.Prelude" }, { "name": "ge_iff_le", "module": "Init.Core" }, { "name": "ne_of_beq_false", "module": "Init.Core" } ]
[ { "name": "arstepstar_add_right", "content": "theorem arstepstar_add_right (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) :\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n ArStepStar V val\n (ArExpr.Add (ArExpr.Const n) eβ‚‚)\n (ArExpr.Add (ArExpr.Const n) eβ‚‚')" }, { "name": "arstepstar_sub_left", "content": "theorem arstepstar_sub_left (e₁ e₁' eβ‚‚: ArExpr V) :\n ArStepStar V val e₁ e₁' ->\n ArStepStar V val\n (ArExpr.Sub e₁ eβ‚‚)\n (ArExpr.Sub e₁' eβ‚‚)" }, { "name": "chasles_step_star", "content": "theorem chasles_step_star {ExprKind: Type} {Step: StepKind V ExprKind} {e₁ eβ‚‚ e₃: ExprKind}:\n StepStar (Step := Step) V val e₁ eβ‚‚ ->\n StepStar (Step := Step) V val eβ‚‚ e₃ ->\n StepStar (Step := Step) V val e₁ e₃" }, { "name": "arstepstar_add_left", "content": "theorem arstepstar_add_left (e₁ e₁' eβ‚‚: ArExpr V) :\n ArStepStar V val e₁ e₁' -> ArStepStar V val (ArExpr.Add e₁ eβ‚‚) (ArExpr.Add e₁' eβ‚‚)" }, { "name": "arstepstar_sub_right", "content": "theorem arstepstar_sub_right (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) :\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n ArStepStar V val\n (ArExpr.Sub (ArExpr.Const n) eβ‚‚)\n (ArExpr.Sub (ArExpr.Const n) eβ‚‚')" }, { "name": "ArStepStar.ifStep", "content": "theorem ArStepStar.ifStep (e e': BoolExpr V) (a b: ArExpr V): BoolStepStar V val e e' ->\n ArStepStar V val (ArExpr.If e a b) (ArExpr.If e' a b)" }, { "name": "arstepstar_mul_right", "content": "theorem arstepstar_mul_right (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) :\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n ArStepStar V val\n (ArExpr.Mul (ArExpr.Const n) eβ‚‚)\n (ArExpr.Mul (ArExpr.Const n) eβ‚‚')" }, { "name": "arstepstar_mul_left", "content": "theorem arstepstar_mul_left (e₁ e₁' eβ‚‚: ArExpr V) :\n ArStepStar V val e₁ e₁' ->\n ArStepStar V val\n (ArExpr.Mul e₁ eβ‚‚)\n (ArExpr.Mul e₁' eβ‚‚)" }, { "name": "BoolStepStar.andStepLeft", "content": "theorem BoolStepStar.andStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStepStar V val e₁ e₁' -> BoolStepStar V val\n (BoolExpr.And e₁ eβ‚‚)\n (BoolExpr.And e₁' eβ‚‚)" }, { "name": "BoolStepStar.lessArStepStarLeft", "content": "theorem BoolStepStar.lessArStepStarLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStepStar V val e₁ e₁' ->\n BoolStepStar V val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁' eβ‚‚)" }, { "name": "BoolStepStar.notStep", "content": "theorem BoolStepStar.notStep {V: Type} {val: V -> Int}\n (e e': BoolExpr V):\n BoolStepStar V val e e' -> BoolStepStar V val (BoolExpr.Not e) (BoolExpr.Not e')" }, { "name": "BoolStepStar.lessArStepStarRight", "content": "theorem BoolStepStar.lessArStepStarRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n BoolStepStar V val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁ eβ‚‚')" }, { "name": "step_to_stepstar", "content": "theorem step_to_stepstar {ExprKind: Type} {Step: StepKind V ExprKind} {e e': ExprKind}:\n Step val e e' -> StepStar (Step := Step) V val e e'" }, { "name": "BoolStepStar.eqArStepStarRight", "content": "theorem BoolStepStar.eqArStepStarRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStepStar V val eβ‚‚ eβ‚‚' ->\n BoolStepStar V val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁ eβ‚‚')" }, { "name": "BoolStepStar.eqArStepStarLeft", "content": "theorem BoolStepStar.eqArStepStarLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStepStar V val e₁ e₁' ->\n BoolStepStar V val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁' eβ‚‚)" }, { "name": "BoolStepStar.orStepLeft", "content": "theorem BoolStepStar.orStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStepStar V val e₁ e₁' -> BoolStepStar V val\n (BoolExpr.Or e₁ eβ‚‚)\n (BoolExpr.Or e₁' eβ‚‚)" } ]
[]
[]
import ExprEval.Steps import ExprEval.Lemmas variable (V: Type)
theorem eval_completeness (e: ArExpr V) : ArStepStar V val e (ArExpr.Const (eval V val e)) :=
:= by cases e with | Const x => simp [eval] exact ArStepStar.refl _ _ | Add e₁ eβ‚‚ => have ih1 := eval_completeness e₁ (val := val) have ih2 := eval_completeness eβ‚‚ (val := val) simp [eval] have a := arstepstar_add_left _ _ eβ‚‚ ih1 have b := arstepstar_add_right (eval V val e₁) eβ‚‚ _ ih2 have c := ArStep.addConstConst (val := val) (eval V val e₁) (eval V val eβ‚‚) have d := ArStepStar.trans _ _ _ c (ArStepStar.refl _ (ArExpr.Const (eval V val e₁ + eval V val eβ‚‚))) have e := chasles_step_star _ a (chasles_step_star _ b d) exact e | Sub e₁ eβ‚‚ => have ih1 := eval_completeness e₁ (val := val) have ih2 := eval_completeness eβ‚‚ (val := val) simp [eval] have a := arstepstar_sub_left _ _ eβ‚‚ ih1 have b := arstepstar_sub_right (eval V val e₁) eβ‚‚ _ ih2 have c := ArStep.subConstConst (val := val) (eval V val e₁) (eval V val eβ‚‚) have d := ArStepStar.trans _ _ _ c (ArStepStar.refl _ (ArExpr.Const (eval V val e₁ - eval V val eβ‚‚))) have e := chasles_step_star _ a (chasles_step_star _ b d) exact e | Mul e₁ eβ‚‚ => have ih1 := eval_completeness e₁ (val := val) have ih2 := eval_completeness eβ‚‚ (val := val) simp [eval] have a := arstepstar_mul_left _ _ eβ‚‚ ih1 have b := arstepstar_mul_right (eval V val e₁) eβ‚‚ _ ih2 have c := ArStep.mulConstConst (val := val) (eval V val e₁) (eval V val eβ‚‚) have d := ArStepStar.trans _ _ _ c (ArStepStar.refl _ (ArExpr.Const (eval V val e₁ * eval V val eβ‚‚))) have e := chasles_step_star _ a (chasles_step_star _ b d) exact e | Var var => simp [eval] have a := ArStep.getVarValue var (val := val) have b := ArStepStar.refl val (ArExpr.Const (val var)) exact ArStepStar.trans (val := val) _ _ _ a b | If cond a b => simp [eval] cases h: (eval_bool V val cond) . simp have h1 := ArStep.ifCondFalse a b (val := val) have h2 := eval_completeness b (val := val) have h3 := StepStar.trans _ _ _ h1 h2 have h4 := eval_bool_completeness cond (val := val) rw [h] at h4 have h5 := ArStepStar.ifStep _ _ a b h4 exact chasles_step_star V h5 h3 . simp have h1 := ArStep.ifCondTrue a b (val := val) have h2 := eval_completeness a (val := val) have h3 := StepStar.trans _ _ _ h1 h2 have h4 := eval_bool_completeness cond (val := val) rw [h] at h4 have h5 := ArStepStar.ifStep _ _ a b h4 exact chasles_step_star V h5 h3
4
60
true
Semantics
267
boolstep_preserves_eval_bool
theorem boolstep_preserves_eval_bool (e e': BoolExpr V): BoolStep V val e e' -> eval_bool V val e = eval_bool V val e'
LeanExprEvaluator
ExprEval/Lemmas.lean
[ "import ExprEval.Steps", "import ExprEval.Expr" ]
[ { "name": "Add", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "Mul", "module": "Init.Prelude" }, { "name": "Sub", "module": "Init.Prelude" }, { "name": "And", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Eq", "module": "Init.Prelude" }, { "name": "Not", "module": "Init.Prelude" }, { "name": "Or", "module": "Init.Prelude" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "ite", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Computation", "module": "Mathlib.Data.Seq.Computation" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Max", "module": "Init.Prelude" }, { "name": "Max.max", "module": "Init.Prelude" } ]
[ { "name": "BoolExpr", "content": "inductive BoolExpr : Type\n | Const: Bool -> BoolExpr\n | Less: ArExpr -> ArExpr -> BoolExpr\n | Eq: ArExpr -> ArExpr -> BoolExpr\n | Not : BoolExpr -> BoolExpr\n | And : BoolExpr -> BoolExpr -> BoolExpr\n | Or : BoolExpr -> BoolExpr -> BoolExpr\n\n inductive ArExpr: Type\n | Const: Int -> ArExpr\n | Add: ArExpr -> ArExpr -> ArExpr\n | Sub: ArExpr -> ArExpr -> ArExpr\n | Mul: ArExpr -> ArExpr -> ArExpr\n | Var: V -> ArExpr\n | If : BoolExpr -> ArExpr -> ArExpr -> ArExpr" }, { "name": "BoolStep", "content": "inductive BoolStep: (val: V -> Int) -> (BoolExpr V) -> (BoolExpr V) -> Prop where\n | notIsBoolNot (b: Bool): BoolStep val\n (BoolExpr.Not (BoolExpr.Const b))\n (BoolExpr.Const !b)\n | andLeftTrue (e: BoolExpr V): BoolStep val\n (BoolExpr.And (BoolExpr.Const true) e)\n e\n | orLeftFalse (e: BoolExpr V): BoolStep val\n (BoolExpr.Or (BoolExpr.Const false) e)\n e\n | andLeftShortCircuit e : BoolStep val\n (BoolExpr.And (BoolExpr.Const false) e)\n (BoolExpr.Const false)\n | orLeftShortCircuit e : BoolStep val\n (BoolExpr.Or (BoolExpr.Const true) e)\n (BoolExpr.Const true)\n | lessConstConstTrue n₁ nβ‚‚ : n₁ < nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | lessConstConstFalse n₁ nβ‚‚ : n₁ >= nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | eqConstConstTrue n₁ nβ‚‚ : n₁ = nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | eqConstConstFalse n₁ nβ‚‚ : n₁ != nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | lessArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁' eβ‚‚)\n | eqArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁' eβ‚‚)\n | lessArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁ eβ‚‚')\n | eqArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁ eβ‚‚')\n | orStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Or e₁ eβ‚‚)\n (BoolExpr.Or e₁' eβ‚‚)\n | andStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.And e₁ eβ‚‚)\n (BoolExpr.And e₁' eβ‚‚)\n | notStep (e e' : BoolExpr V):\n BoolStep val e e' -> BoolStep val\n (BoolExpr.Not e)\n (BoolExpr.Not e')\n\n def eval (val: V -> Int) (e: ArExpr V) : Int :=\n match e with\n | ArExpr.Const x => x\n | ArExpr.Add lhs rhs => (eval val lhs) + (eval val rhs)\n | ArExpr.Sub lhs rhs => (eval val lhs) - (eval val rhs)\n | ArExpr.Mul lhs rhs => (eval val lhs) * (eval val rhs)\n | ArExpr.Var v => val v\n | ArExpr.If cond then_e else_e => if eval_bool val cond then eval val then_e else eval val else_e\n\n def eval_bool (val: V -> Int) (e: BoolExpr V): Bool :=\n match e with\n | BoolExpr.Const b => b\n | BoolExpr.Less l r => (eval val l) < (eval val r)\n | BoolExpr.Eq l r => (eval val l) == (eval val r)\n | BoolExpr.Not e => not (eval_bool val e)\n | BoolExpr.And l r => if eval_bool val l then eval_bool val r else false\n | BoolExpr.Or l r => if eval_bool val l then true else eval_bool val r" }, { "name": "ArStep", "content": "inductive ArStep: (val: V -> Int) -> (ArExpr V) -> (ArExpr V) -> Prop where\n | getVarValue (var: V) :\n ArStep\n val\n (ArExpr.Var var)\n (ArExpr.Const (val var))\n | addConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Add (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ + nβ‚‚))\n | subConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Sub (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ - nβ‚‚))\n | mulConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Mul (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ * nβ‚‚))\n | addLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Add e₁ eβ‚‚) (ArExpr.Add e₁' eβ‚‚)\n\n | subLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Sub e₁ eβ‚‚) (ArExpr.Sub e₁' eβ‚‚)\n\n | mulLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Mul e₁ eβ‚‚) (ArExpr.Mul e₁' eβ‚‚)\n\n | addRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Add (ArExpr.Const n) eβ‚‚) (ArExpr.Add (ArExpr.Const n) eβ‚‚')\n\n | subRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Sub (ArExpr.Const n) eβ‚‚) (ArExpr.Sub (ArExpr.Const n) eβ‚‚')\n | mulRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Mul (ArExpr.Const n) eβ‚‚) (ArExpr.Mul (ArExpr.Const n) eβ‚‚')\n\n | ifStep (e e': BoolExpr V) (a b : ArExpr V): BoolStep val e e' ->\n ArStep val (ArExpr.If e a b) (ArExpr.If e' a b)\n | ifCondTrue (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const true) a b) a\n | ifCondFalse (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const false) a b) b" } ]
[ { "name": "bne_iff_ne", "module": "Init.SimpLemmas" }, { "name": "Int.mul_eq_mul_right_iff", "module": "Init.Data.Int.Lemmas" }, { "name": "beq_eq_false_iff_ne", "module": "Init.SimpLemmas" }, { "name": "beq_iff_eq", "module": "Init.Core" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[ { "name": "arstep_preserve_eval", "content": " theorem arstep_preserve_eval (e e': ArExpr V): (ArStep V val) e e' -> eval V val e = eval V val e'" } ]
import ExprEval.Expr import ExprEval.Steps
theorem boolstep_preserves_eval_bool (e e': BoolExpr V): BoolStep V val e e' -> eval_bool V val e = eval_bool V val e' :=
:= by intro h cases h with | notIsBoolNot b => simp [eval_bool] | andLeftTrue e => simp [eval_bool] | orLeftFalse e => simp [eval_bool] | andLeftShortCircuit e => simp [eval_bool] | orLeftShortCircuit e => simp [eval_bool] | lessConstConstTrue n1 n2 h => simp [eval_bool] simp [eval] exact h | lessConstConstFalse n1 n2 h => simp [eval_bool] simp [eval] exact h | eqConstConstTrue n1 n2 h => simp [eval_bool] simp [eval] exact h | eqConstConstFalse n1 n2 h => simp [eval_bool] simp [eval] simp [bne_iff_ne] at h exact h | lessArStepLeft e₁ e₁' eβ‚‚ arstep | eqArStepLeft e₁ e₁' eβ‚‚ arstep => simp [eval_bool] have h' := arstep_preserve_eval e₁ e₁' arstep rw [h'] | lessArStepRight e₁ eβ‚‚ eβ‚‚' arstep | eqArStepRight e₁ eβ‚‚ eβ‚‚' arstep => simp [eval_bool] have h' := arstep_preserve_eval eβ‚‚ eβ‚‚' arstep rw [h'] | orStepLeft e₁ e₁' eβ‚‚ step | andStepLeft e₁ e₁' eβ‚‚ step => have ihn := boolstep_preserves_eval_bool e₁ e₁' step simp [eval_bool] rw [ihn] | notStep e e' step => simp[eval_bool] have ihn := boolstep_preserves_eval_bool e e' step rw [ihn]
3
33
false
Semantics
268
arstep_preserve_eval
theorem arstep_preserve_eval (e e': ArExpr V): (ArStep V val) e e' -> eval V val e = eval V val e'
LeanExprEvaluator
ExprEval/Lemmas.lean
[ "import ExprEval.Steps", "import ExprEval.Expr" ]
[ { "name": "Add", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "Mul", "module": "Init.Prelude" }, { "name": "Sub", "module": "Init.Prelude" }, { "name": "And", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Eq", "module": "Init.Prelude" }, { "name": "Not", "module": "Init.Prelude" }, { "name": "Or", "module": "Init.Prelude" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "ite", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Computation", "module": "Mathlib.Data.Seq.Computation" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Max", "module": "Init.Prelude" }, { "name": "Max.max", "module": "Init.Prelude" } ]
[ { "name": "ArStep", "content": "inductive ArStep: (val: V -> Int) -> (ArExpr V) -> (ArExpr V) -> Prop where\n | getVarValue (var: V) :\n ArStep\n val\n (ArExpr.Var var)\n (ArExpr.Const (val var))\n | addConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Add (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ + nβ‚‚))\n | subConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Sub (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ - nβ‚‚))\n | mulConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Mul (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ * nβ‚‚))\n | addLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Add e₁ eβ‚‚) (ArExpr.Add e₁' eβ‚‚)\n\n | subLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Sub e₁ eβ‚‚) (ArExpr.Sub e₁' eβ‚‚)\n\n | mulLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Mul e₁ eβ‚‚) (ArExpr.Mul e₁' eβ‚‚)\n\n | addRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Add (ArExpr.Const n) eβ‚‚) (ArExpr.Add (ArExpr.Const n) eβ‚‚')\n\n | subRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Sub (ArExpr.Const n) eβ‚‚) (ArExpr.Sub (ArExpr.Const n) eβ‚‚')\n | mulRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Mul (ArExpr.Const n) eβ‚‚) (ArExpr.Mul (ArExpr.Const n) eβ‚‚')\n\n | ifStep (e e': BoolExpr V) (a b : ArExpr V): BoolStep val e e' ->\n ArStep val (ArExpr.If e a b) (ArExpr.If e' a b)\n | ifCondTrue (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const true) a b) a\n | ifCondFalse (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const false) a b) b" }, { "name": "BoolStep", "content": "inductive BoolStep: (val: V -> Int) -> (BoolExpr V) -> (BoolExpr V) -> Prop where\n | notIsBoolNot (b: Bool): BoolStep val\n (BoolExpr.Not (BoolExpr.Const b))\n (BoolExpr.Const !b)\n | andLeftTrue (e: BoolExpr V): BoolStep val\n (BoolExpr.And (BoolExpr.Const true) e)\n e\n | orLeftFalse (e: BoolExpr V): BoolStep val\n (BoolExpr.Or (BoolExpr.Const false) e)\n e\n | andLeftShortCircuit e : BoolStep val\n (BoolExpr.And (BoolExpr.Const false) e)\n (BoolExpr.Const false)\n | orLeftShortCircuit e : BoolStep val\n (BoolExpr.Or (BoolExpr.Const true) e)\n (BoolExpr.Const true)\n | lessConstConstTrue n₁ nβ‚‚ : n₁ < nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | lessConstConstFalse n₁ nβ‚‚ : n₁ >= nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | eqConstConstTrue n₁ nβ‚‚ : n₁ = nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | eqConstConstFalse n₁ nβ‚‚ : n₁ != nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | lessArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁' eβ‚‚)\n | eqArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁' eβ‚‚)\n | lessArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁ eβ‚‚')\n | eqArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁ eβ‚‚')\n | orStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Or e₁ eβ‚‚)\n (BoolExpr.Or e₁' eβ‚‚)\n | andStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.And e₁ eβ‚‚)\n (BoolExpr.And e₁' eβ‚‚)\n | notStep (e e' : BoolExpr V):\n BoolStep val e e' -> BoolStep val\n (BoolExpr.Not e)\n (BoolExpr.Not e')\n\n inductive BoolExpr : Type\n | Const: Bool -> BoolExpr\n | Less: ArExpr -> ArExpr -> BoolExpr\n | Eq: ArExpr -> ArExpr -> BoolExpr\n | Not : BoolExpr -> BoolExpr\n | And : BoolExpr -> BoolExpr -> BoolExpr\n | Or : BoolExpr -> BoolExpr -> BoolExpr\n\n inductive ArExpr: Type\n | Const: Int -> ArExpr\n | Add: ArExpr -> ArExpr -> ArExpr\n | Sub: ArExpr -> ArExpr -> ArExpr\n | Mul: ArExpr -> ArExpr -> ArExpr\n | Var: V -> ArExpr\n | If : BoolExpr -> ArExpr -> ArExpr -> ArExpr\n\n def eval (val: V -> Int) (e: ArExpr V) : Int :=\n match e with\n | ArExpr.Const x => x\n | ArExpr.Add lhs rhs => (eval val lhs) + (eval val rhs)\n | ArExpr.Sub lhs rhs => (eval val lhs) - (eval val rhs)\n | ArExpr.Mul lhs rhs => (eval val lhs) * (eval val rhs)\n | ArExpr.Var v => val v\n | ArExpr.If cond then_e else_e => if eval_bool val cond then eval val then_e else eval val else_e\n\n def eval_bool (val: V -> Int) (e: BoolExpr V): Bool :=\n match e with\n | BoolExpr.Const b => b\n | BoolExpr.Less l r => (eval val l) < (eval val r)\n | BoolExpr.Eq l r => (eval val l) == (eval val r)\n | BoolExpr.Not e => not (eval_bool val e)\n | BoolExpr.And l r => if eval_bool val l then eval_bool val r else false\n | BoolExpr.Or l r => if eval_bool val l then true else eval_bool val r" } ]
[ { "name": "Int.mul_eq_mul_right_iff", "module": "Init.Data.Int.Lemmas" }, { "name": "beq_eq_false_iff_ne", "module": "Init.SimpLemmas" }, { "name": "beq_iff_eq", "module": "Init.Core" }, { "name": "bne_iff_ne", "module": "Init.SimpLemmas" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[]
import ExprEval.Expr import ExprEval.Steps
theorem arstep_preserve_eval (e e': ArExpr V): (ArStep V val) e e' -> eval V val e = eval V val e' :=
:= by intro h cases h with | addConstConst n₁ nβ‚‚ | subConstConst n₁ nβ‚‚ | mulConstConst n₁ nβ‚‚ => simp [eval] | subLeft e₁ e₁' eβ‚‚ step | addLeft e₁ e₁' eβ‚‚ step => simp [eval] exact arstep_preserve_eval e₁ e₁' step | mulLeft e₁ e₁' eβ‚‚ step => simp [eval] cases h : (eval V val eβ‚‚ == 0) . rw [beq_eq_false_iff_ne] at h rw [Int.mul_eq_mul_right_iff] exact arstep_preserve_eval e₁ e₁' step exact h . rw [beq_iff_eq] at h rw [h] simp | addRight n eβ‚‚ e₁' step | subRight n eβ‚‚ e₁' step | mulRight n eβ‚‚ e₁' step => -- have ih := arstep_preserve_eval e₁ e₁' step have ihn := arstep_preserve_eval eβ‚‚ e₁' step simp [eval, ihn] | getVarValue var => simp [eval] | ifCondTrue a b => simp [eval] simp [eval_bool] | ifCondFalse a b => simp [eval] simp [eval_bool] | ifStep e e' a b bstep => have ihn := boolstep_preserves_eval_bool e e' bstep cases h: (eval_bool V val e) . simp [eval] rw [h] rw [<- ihn] simp intro noth rw [h] at noth nomatch noth . simp [eval] rw [h] rw [<- ihn] simp intro noth rw [h] at noth nomatch noth
4
33
true
Semantics
269
boolstepstar_preserves_eval_bool
theorem boolstepstar_preserves_eval_bool (e e': BoolExpr V): BoolStepStar V val e e' -> eval_bool V val e = eval_bool V val e'
LeanExprEvaluator
ExprEval/Lemmas.lean
[ "import ExprEval.Steps", "import ExprEval.Expr" ]
[ { "name": "Add", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "Mul", "module": "Init.Prelude" }, { "name": "Sub", "module": "Init.Prelude" }, { "name": "And", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Eq", "module": "Init.Prelude" }, { "name": "Not", "module": "Init.Prelude" }, { "name": "Or", "module": "Init.Prelude" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "ite", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Computation", "module": "Mathlib.Data.Seq.Computation" }, { "name": "Max", "module": "Init.Prelude" }, { "name": "Max.max", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" } ]
[ { "name": "BoolExpr", "content": "inductive BoolExpr : Type\n | Const: Bool -> BoolExpr\n | Less: ArExpr -> ArExpr -> BoolExpr\n | Eq: ArExpr -> ArExpr -> BoolExpr\n | Not : BoolExpr -> BoolExpr\n | And : BoolExpr -> BoolExpr -> BoolExpr\n | Or : BoolExpr -> BoolExpr -> BoolExpr\n\n inductive ArExpr: Type\n | Const: Int -> ArExpr\n | Add: ArExpr -> ArExpr -> ArExpr\n | Sub: ArExpr -> ArExpr -> ArExpr\n | Mul: ArExpr -> ArExpr -> ArExpr\n | Var: V -> ArExpr\n | If : BoolExpr -> ArExpr -> ArExpr -> ArExpr" }, { "name": "BoolStepStar", "content": "def BoolStepStar (V: Type) := StepStar (Step := BoolStep V) V" }, { "name": "BoolStep", "content": "inductive BoolStep: (val: V -> Int) -> (BoolExpr V) -> (BoolExpr V) -> Prop where\n | notIsBoolNot (b: Bool): BoolStep val\n (BoolExpr.Not (BoolExpr.Const b))\n (BoolExpr.Const !b)\n | andLeftTrue (e: BoolExpr V): BoolStep val\n (BoolExpr.And (BoolExpr.Const true) e)\n e\n | orLeftFalse (e: BoolExpr V): BoolStep val\n (BoolExpr.Or (BoolExpr.Const false) e)\n e\n | andLeftShortCircuit e : BoolStep val\n (BoolExpr.And (BoolExpr.Const false) e)\n (BoolExpr.Const false)\n | orLeftShortCircuit e : BoolStep val\n (BoolExpr.Or (BoolExpr.Const true) e)\n (BoolExpr.Const true)\n | lessConstConstTrue n₁ nβ‚‚ : n₁ < nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | lessConstConstFalse n₁ nβ‚‚ : n₁ >= nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | eqConstConstTrue n₁ nβ‚‚ : n₁ = nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | eqConstConstFalse n₁ nβ‚‚ : n₁ != nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | lessArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁' eβ‚‚)\n | eqArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁' eβ‚‚)\n | lessArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁ eβ‚‚')\n | eqArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁ eβ‚‚')\n | orStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Or e₁ eβ‚‚)\n (BoolExpr.Or e₁' eβ‚‚)\n | andStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.And e₁ eβ‚‚)\n (BoolExpr.And e₁' eβ‚‚)\n | notStep (e e' : BoolExpr V):\n BoolStep val e e' -> BoolStep val\n (BoolExpr.Not e)\n (BoolExpr.Not e')" }, { "name": "ArStep", "content": "inductive ArStep: (val: V -> Int) -> (ArExpr V) -> (ArExpr V) -> Prop where\n | getVarValue (var: V) :\n ArStep\n val\n (ArExpr.Var var)\n (ArExpr.Const (val var))\n | addConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Add (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ + nβ‚‚))\n | subConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Sub (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ - nβ‚‚))\n | mulConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Mul (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ * nβ‚‚))\n | addLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Add e₁ eβ‚‚) (ArExpr.Add e₁' eβ‚‚)\n\n | subLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Sub e₁ eβ‚‚) (ArExpr.Sub e₁' eβ‚‚)\n\n | mulLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Mul e₁ eβ‚‚) (ArExpr.Mul e₁' eβ‚‚)\n\n | addRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Add (ArExpr.Const n) eβ‚‚) (ArExpr.Add (ArExpr.Const n) eβ‚‚')\n\n | subRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Sub (ArExpr.Const n) eβ‚‚) (ArExpr.Sub (ArExpr.Const n) eβ‚‚')\n | mulRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Mul (ArExpr.Const n) eβ‚‚) (ArExpr.Mul (ArExpr.Const n) eβ‚‚')\n\n | ifStep (e e': BoolExpr V) (a b : ArExpr V): BoolStep val e e' ->\n ArStep val (ArExpr.If e a b) (ArExpr.If e' a b)\n | ifCondTrue (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const true) a b) a\n | ifCondFalse (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const false) a b) b" }, { "name": "StepStar", "content": "inductive StepStar {ExprType: Type} {Step: StepKind V ExprType} : (val: V -> Int) -> ExprType -> ExprType -> Prop where\n | refl val e : StepStar val e e\n | trans e₁ eβ‚‚ e₃ : Step val e₁ eβ‚‚ -> StepStar val eβ‚‚ e₃ -> StepStar val e₁ e₃\n\n def eval_bool (val: V -> Int) (e: BoolExpr V): Bool :=\n match e with\n | BoolExpr.Const b => b\n | BoolExpr.Less l r => (eval val l) < (eval val r)\n | BoolExpr.Eq l r => (eval val l) == (eval val r)\n | BoolExpr.Not e => not (eval_bool val e)\n | BoolExpr.And l r => if eval_bool val l then eval_bool val r else false\n | BoolExpr.Or l r => if eval_bool val l then true else eval_bool val r\n\n def eval (val: V -> Int) (e: ArExpr V) : Int :=\n match e with\n | ArExpr.Const x => x\n | ArExpr.Add lhs rhs => (eval val lhs) + (eval val rhs)\n | ArExpr.Sub lhs rhs => (eval val lhs) - (eval val rhs)\n | ArExpr.Mul lhs rhs => (eval val lhs) * (eval val rhs)\n | ArExpr.Var v => val v\n | ArExpr.If cond then_e else_e => if eval_bool val cond then eval val then_e else eval val else_e" } ]
[ { "name": "Int.mul_eq_mul_right_iff", "module": "Init.Data.Int.Lemmas" }, { "name": "beq_eq_false_iff_ne", "module": "Init.SimpLemmas" }, { "name": "beq_iff_eq", "module": "Init.Core" }, { "name": "bne_iff_ne", "module": "Init.SimpLemmas" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[ { "name": "arstep_preserve_eval", "content": " theorem arstep_preserve_eval (e e': ArExpr V): (ArStep V val) e e' -> eval V val e = eval V val e'" }, { "name": "boolstep_preserves_eval_bool", "content": " theorem boolstep_preserves_eval_bool (e e': BoolExpr V):\n BoolStep V val e e' -> eval_bool V val e = eval_bool V val e'" } ]
import ExprEval.Expr import ExprEval.Steps
theorem boolstepstar_preserves_eval_bool (e e': BoolExpr V): BoolStepStar V val e e' -> eval_bool V val e = eval_bool V val e' :=
:= by intro h induction h with | refl => rfl | trans _ _ _ h_step _ ihn => rw [<- ihn] exact boolstep_preserves_eval_bool _ _ h_step
4
35
false
Semantics
270
arstepstar_preserves_eval
theorem arstepstar_preserves_eval (e e': ArExpr V) : ArStepStar V val e e' -> eval V val e = eval V val e'
LeanExprEvaluator
ExprEval/Lemmas.lean
[ "import ExprEval.Steps", "import ExprEval.Expr" ]
[ { "name": "And", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Eq", "module": "Init.Prelude" }, { "name": "Not", "module": "Init.Prelude" }, { "name": "Or", "module": "Init.Prelude" }, { "name": "Add", "module": "Init.Prelude" }, { "name": "Int", "module": "Init.Data.Int.Basic" }, { "name": "Mul", "module": "Init.Prelude" }, { "name": "Sub", "module": "Init.Prelude" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "String", "module": "Init.Prelude" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "ite", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Computation", "module": "Mathlib.Data.Seq.Computation" }, { "name": "Max", "module": "Init.Prelude" }, { "name": "Max.max", "module": "Init.Prelude" }, { "name": "Option", "module": "Init.Prelude" } ]
[ { "name": "ArExpr", "content": "inductive ArExpr: Type\n | Const: Int -> ArExpr\n | Add: ArExpr -> ArExpr -> ArExpr\n | Sub: ArExpr -> ArExpr -> ArExpr\n | Mul: ArExpr -> ArExpr -> ArExpr\n | Var: V -> ArExpr\n | If : BoolExpr -> ArExpr -> ArExpr -> ArExpr\n\n inductive BoolExpr : Type\n | Const: Bool -> BoolExpr\n | Less: ArExpr -> ArExpr -> BoolExpr\n | Eq: ArExpr -> ArExpr -> BoolExpr\n | Not : BoolExpr -> BoolExpr\n | And : BoolExpr -> BoolExpr -> BoolExpr\n | Or : BoolExpr -> BoolExpr -> BoolExpr" }, { "name": "ArStepStar", "content": "def ArStepStar (V: Type) := StepStar (Step := ArStep V) V" }, { "name": "ArStep", "content": "inductive ArStep: (val: V -> Int) -> (ArExpr V) -> (ArExpr V) -> Prop where\n | getVarValue (var: V) :\n ArStep\n val\n (ArExpr.Var var)\n (ArExpr.Const (val var))\n | addConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Add (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ + nβ‚‚))\n | subConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Sub (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ - nβ‚‚))\n | mulConstConst(n₁ nβ‚‚: Int) :\n ArStep\n val\n (ArExpr.Mul (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (ArExpr.Const (n₁ * nβ‚‚))\n | addLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Add e₁ eβ‚‚) (ArExpr.Add e₁' eβ‚‚)\n\n | subLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Sub e₁ eβ‚‚) (ArExpr.Sub e₁' eβ‚‚)\n\n | mulLeft (e₁ e₁' eβ‚‚) : ArStep val e₁ e₁' -> ArStep val (ArExpr.Mul e₁ eβ‚‚) (ArExpr.Mul e₁' eβ‚‚)\n\n | addRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Add (ArExpr.Const n) eβ‚‚) (ArExpr.Add (ArExpr.Const n) eβ‚‚')\n\n | subRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Sub (ArExpr.Const n) eβ‚‚) (ArExpr.Sub (ArExpr.Const n) eβ‚‚')\n | mulRight (n: Int) (eβ‚‚ eβ‚‚': ArExpr V) : ArStep val eβ‚‚ eβ‚‚' -> ArStep val (ArExpr.Mul (ArExpr.Const n) eβ‚‚) (ArExpr.Mul (ArExpr.Const n) eβ‚‚')\n\n | ifStep (e e': BoolExpr V) (a b : ArExpr V): BoolStep val e e' ->\n ArStep val (ArExpr.If e a b) (ArExpr.If e' a b)\n | ifCondTrue (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const true) a b) a\n | ifCondFalse (a b: ArExpr V) : ArStep val (ArExpr.If (BoolExpr.Const false) a b) b" }, { "name": "BoolStep", "content": "inductive BoolStep: (val: V -> Int) -> (BoolExpr V) -> (BoolExpr V) -> Prop where\n | notIsBoolNot (b: Bool): BoolStep val\n (BoolExpr.Not (BoolExpr.Const b))\n (BoolExpr.Const !b)\n | andLeftTrue (e: BoolExpr V): BoolStep val\n (BoolExpr.And (BoolExpr.Const true) e)\n e\n | orLeftFalse (e: BoolExpr V): BoolStep val\n (BoolExpr.Or (BoolExpr.Const false) e)\n e\n | andLeftShortCircuit e : BoolStep val\n (BoolExpr.And (BoolExpr.Const false) e)\n (BoolExpr.Const false)\n | orLeftShortCircuit e : BoolStep val\n (BoolExpr.Or (BoolExpr.Const true) e)\n (BoolExpr.Const true)\n | lessConstConstTrue n₁ nβ‚‚ : n₁ < nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | lessConstConstFalse n₁ nβ‚‚ : n₁ >= nβ‚‚ -> BoolStep val\n (BoolExpr.Less (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | eqConstConstTrue n₁ nβ‚‚ : n₁ = nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const true)\n | eqConstConstFalse n₁ nβ‚‚ : n₁ != nβ‚‚ -> BoolStep val\n (BoolExpr.Eq (ArExpr.Const n₁) (ArExpr.Const nβ‚‚))\n (BoolExpr.Const false)\n | lessArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁' eβ‚‚)\n | eqArStepLeft (e₁ e₁' eβ‚‚: ArExpr V):\n ArStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁' eβ‚‚)\n | lessArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Less e₁ eβ‚‚)\n (BoolExpr.Less e₁ eβ‚‚')\n | eqArStepRight (e₁ eβ‚‚ eβ‚‚': ArExpr V):\n ArStep val eβ‚‚ eβ‚‚' ->\n BoolStep val\n (BoolExpr.Eq e₁ eβ‚‚)\n (BoolExpr.Eq e₁ eβ‚‚')\n | orStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.Or e₁ eβ‚‚)\n (BoolExpr.Or e₁' eβ‚‚)\n | andStepLeft (e₁ e₁' eβ‚‚: BoolExpr V):\n BoolStep val e₁ e₁' ->\n BoolStep val\n (BoolExpr.And e₁ eβ‚‚)\n (BoolExpr.And e₁' eβ‚‚)\n | notStep (e e' : BoolExpr V):\n BoolStep val e e' -> BoolStep val\n (BoolExpr.Not e)\n (BoolExpr.Not e')" }, { "name": "StepStar", "content": "inductive StepStar {ExprType: Type} {Step: StepKind V ExprType} : (val: V -> Int) -> ExprType -> ExprType -> Prop where\n | refl val e : StepStar val e e\n | trans e₁ eβ‚‚ e₃ : Step val e₁ eβ‚‚ -> StepStar val eβ‚‚ e₃ -> StepStar val e₁ e₃\n\n def eval (val: V -> Int) (e: ArExpr V) : Int :=\n match e with\n | ArExpr.Const x => x\n | ArExpr.Add lhs rhs => (eval val lhs) + (eval val rhs)\n | ArExpr.Sub lhs rhs => (eval val lhs) - (eval val rhs)\n | ArExpr.Mul lhs rhs => (eval val lhs) * (eval val rhs)\n | ArExpr.Var v => val v\n | ArExpr.If cond then_e else_e => if eval_bool val cond then eval val then_e else eval val else_e\n\n def eval_bool (val: V -> Int) (e: BoolExpr V): Bool :=\n match e with\n | BoolExpr.Const b => b\n | BoolExpr.Less l r => (eval val l) < (eval val r)\n | BoolExpr.Eq l r => (eval val l) == (eval val r)\n | BoolExpr.Not e => not (eval_bool val e)\n | BoolExpr.And l r => if eval_bool val l then eval_bool val r else false\n | BoolExpr.Or l r => if eval_bool val l then true else eval_bool val r" } ]
[ { "name": "bne_iff_ne", "module": "Init.SimpLemmas" }, { "name": "Int.mul_eq_mul_right_iff", "module": "Init.Data.Int.Lemmas" }, { "name": "beq_eq_false_iff_ne", "module": "Init.SimpLemmas" }, { "name": "beq_iff_eq", "module": "Init.Core" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[ { "name": "arstep_preserve_eval", "content": " theorem arstep_preserve_eval (e e': ArExpr V): (ArStep V val) e e' -> eval V val e = eval V val e'" } ]
import ExprEval.Expr import ExprEval.Steps
theorem arstepstar_preserves_eval (e e': ArExpr V) : ArStepStar V val e e' -> eval V val e = eval V val e' :=
:= by intro h induction h with | refl _ => rfl | trans _ _ _ h1 _ ih => rw [arstep_preserve_eval _ _ h1, ih]
3
35
false
Semantics
271
TM.progress
theorem progress t T : HasType t T β†’ value t ∨ βˆƒ t', Step t t'
lean-formal-reasoning-program
Frap/Types.lean
[ "import Frap.SmallStep" ]
[ { "name": "structure BitVec (w : Nat) where", "module": "" }, { "name": "/-- Construct a `BitVec w` from a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "ofFin ::", "module": "" }, { "name": "/-- Interpret a bitvector as a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "toFin : Fin (hPow 2 w)", "module": "" } ]
[ { "name": "syntax term \"==>\" term : term", "content": "syntax term \"==>\" term : term\n\nsyntax term \"~~>\" term : term\n\nsyntax term \"~~>*\" term : term\n\nsyntax:30 term \" =[ \" imp \" ]=> \" term : term\n\nsyntax term \"!->\" term \"; \" term : term\n\nsyntax:36 term \"<<->>\" term : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$t:term ==> $n:term) => `(Eval $t $n)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$t₁:term ~~> $tβ‚‚:term) => `(Step $t₁ $tβ‚‚)\n\nexample :\n p\n (p (c 1) (c 3))\n (p (c 2) (c 4))\n ~~>\n p\n (c 4)\n (p (c 2) (c 4)) := by admit /- proof elided -/" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$t₁:term ~~>* $tβ‚‚:term) => `(Multi Step $t₁ $tβ‚‚)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$p <<->> $q) => `($p ->> $q ∧ $q ->> $p)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|{*$p*} $c {*$q*}) => `(valid_hoare_triple $p $c $q)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$st =[ $c ]=> $st') => `(CEval <{$c}> $st $st')" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$x:term !-> $a:term ; $st) => `(update $st $x $a)\n\nexample : empty =[\n x := 2;\n if (x <= 1) then y := 3 else z := 4 end\n ]=> (z !-> 4; x !-> 2; empty) := by admit /- proof elided -/" }, { "name": "Step", "content": "inductive Step : Tm β†’ Tm β†’ Prop :=\n | st_ifTrue t₁ tβ‚‚ : Step (ite tru t₁ tβ‚‚) t₁\n | st_ifFalse t₁ tβ‚‚ : Step (ite fls t₁ tβ‚‚) tβ‚‚\n | st_if c c' t₁ tβ‚‚ :\n Step c c' β†’ Step (ite c t₁ tβ‚‚) (ite c' t₁ tβ‚‚)\n | st_succ t₁ t₁' : Step t₁ t₁' β†’ Step (scc t₁) (scc t₁')\n | st_pred0 : Step (prd zro) zro\n | st_predSucc v : NValue v β†’ Step (prd (scc v)) v\n | st_pred t₁ t₁' : Step t₁ t₁' β†’ Step (prd t₁) (prd t₁')\n | st_iszero0 : Step (iszero zro) tru\n | st_iszeroSucc v : NValue v β†’ Step (iszero (scc v)) fls\n | st_iszero t₁ t₁' :\n Step t₁ t₁' β†’ Step (iszero t₁) (iszero t₁')" }, { "name": "Tm", "content": "inductive Tm : Type :=\n | tru : Tm\n | fls : Tm\n | ite : Tm β†’ Tm β†’ Tm β†’ Tm\n | zro : Tm\n | scc : Tm β†’ Tm\n | prd : Tm β†’ Tm\n | iszero : Tm β†’ Tm" }, { "name": "NValue", "content": "inductive NValue : Tm β†’ Prop :=\n | nv_0 : NValue zro\n | nv_succ t : NValue t β†’ NValue (scc t)" }, { "name": "Ty", "content": "inductive Ty : Type :=\n | bool : Ty\n | nat : Ty" }, { "name": "HasType", "content": "inductive HasType : Tm β†’ Ty β†’ Prop :=\n | t_true : HasType tru bool\n | t_false : HasType fls bool\n | t_if t₁ tβ‚‚ t₃ T :\n HasType t₁ bool β†’ HasType tβ‚‚ T β†’ HasType t₃ T\n β†’ HasType (ite t₁ tβ‚‚ t₃) T\n | t_0 : HasType zro nat\n | t_succ t₁ : HasType t₁ nat β†’ HasType (scc t₁) nat\n | t_pred t₁ : HasType t₁ nat β†’ HasType (prd t₁) nat\n | t_iszero t₁ : HasType t₁ nat β†’ HasType (iszero t₁) bool" }, { "name": "Tm", "content": "inductive Tm : Type :=\n | c : Nat β†’ Tm \n | p : Tm β†’ Tm β†’ Tm " }, { "name": "BValue", "content": "inductive BValue : Tm β†’ Prop :=\n | bv_true : BValue tru\n | bv_false : BValue fls" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "TM.Tm", "content": "inductive Tm : Type :=\n | tru : Tm\n | fls : Tm\n | ite : Tm β†’ Tm β†’ Tm β†’ Tm\n | zro : Tm\n | scc : Tm β†’ Tm\n | prd : Tm β†’ Tm\n | iszero : Tm β†’ Tm" }, { "name": "TM.BValue", "content": "inductive BValue : Tm β†’ Prop :=\n | bv_true : BValue tru\n | bv_false : BValue fls" }, { "name": "TM.NValue", "content": "inductive NValue : Tm β†’ Prop :=\n | nv_0 : NValue zro\n | nv_succ t : NValue t β†’ NValue (scc t)" }, { "name": "TM.value", "content": "abbrev value (t : Tm) := BValue t ∨ NValue t" }, { "name": "TM.Step", "content": "inductive Step : Tm β†’ Tm β†’ Prop :=\n | st_ifTrue t₁ tβ‚‚ : Step (ite tru t₁ tβ‚‚) t₁\n | st_ifFalse t₁ tβ‚‚ : Step (ite fls t₁ tβ‚‚) tβ‚‚\n | st_if c c' t₁ tβ‚‚ :\n Step c c' β†’ Step (ite c t₁ tβ‚‚) (ite c' t₁ tβ‚‚)\n | st_succ t₁ t₁' : Step t₁ t₁' β†’ Step (scc t₁) (scc t₁')\n | st_pred0 : Step (prd zro) zro\n | st_predSucc v : NValue v β†’ Step (prd (scc v)) v\n | st_pred t₁ t₁' : Step t₁ t₁' β†’ Step (prd t₁) (prd t₁')\n | st_iszero0 : Step (iszero zro) tru\n | st_iszeroSucc v : NValue v β†’ Step (iszero (scc v)) fls\n | st_iszero t₁ t₁' :\n Step t₁ t₁' β†’ Step (iszero t₁) (iszero t₁')" }, { "name": "TM.Ty", "content": "inductive Ty : Type :=\n | bool : Ty\n | nat : Ty" }, { "name": "TM.HasType", "content": "inductive HasType : Tm β†’ Ty β†’ Prop :=\n | t_true : HasType tru bool\n | t_false : HasType fls bool\n | t_if t₁ tβ‚‚ t₃ T :\n HasType t₁ bool β†’ HasType tβ‚‚ T β†’ HasType t₃ T\n β†’ HasType (ite t₁ tβ‚‚ t₃) T\n | t_0 : HasType zro nat\n | t_succ t₁ : HasType t₁ nat β†’ HasType (scc t₁) nat\n | t_pred t₁ : HasType t₁ nat β†’ HasType (prd t₁) nat\n | t_iszero t₁ : HasType t₁ nat β†’ HasType (iszero t₁) bool" } ]
[ { "name": "TM.bool_canonical", "content": "theorem bool_canonical t : HasType t bool β†’ value t β†’ BValue t" }, { "name": "TM.nat_canonical", "content": "theorem nat_canonical t : HasType t nat β†’ value t β†’ NValue t" } ]
import Frap.SmallStep namespace TM inductive Tm : Type := | tru : Tm | fls : Tm | ite : Tm β†’ Tm β†’ Tm β†’ Tm | zro : Tm | scc : Tm β†’ Tm | prd : Tm β†’ Tm | iszero : Tm β†’ Tm open Tm inductive BValue : Tm β†’ Prop := | bv_true : BValue tru | bv_false : BValue fls inductive NValue : Tm β†’ Prop := | nv_0 : NValue zro | nv_succ t : NValue t β†’ NValue (scc t) open BValue open NValue abbrev value (t : Tm) := BValue t ∨ NValue t inductive Step : Tm β†’ Tm β†’ Prop := | st_ifTrue t₁ tβ‚‚ : Step (ite tru t₁ tβ‚‚) t₁ | st_ifFalse t₁ tβ‚‚ : Step (ite fls t₁ tβ‚‚) tβ‚‚ | st_if c c' t₁ tβ‚‚ : Step c c' β†’ Step (ite c t₁ tβ‚‚) (ite c' t₁ tβ‚‚) | st_succ t₁ t₁' : Step t₁ t₁' β†’ Step (scc t₁) (scc t₁') | st_pred0 : Step (prd zro) zro | st_predSucc v : NValue v β†’ Step (prd (scc v)) v | st_pred t₁ t₁' : Step t₁ t₁' β†’ Step (prd t₁) (prd t₁') | st_iszero0 : Step (iszero zro) tru | st_iszeroSucc v : NValue v β†’ Step (iszero (scc v)) fls | st_iszero t₁ t₁' : Step t₁ t₁' β†’ Step (iszero t₁) (iszero t₁') open Step inductive Ty : Type := | bool : Ty | nat : Ty open Ty inductive HasType : Tm β†’ Ty β†’ Prop := | t_true : HasType tru bool | t_false : HasType fls bool | t_if t₁ tβ‚‚ t₃ T : HasType t₁ bool β†’ HasType tβ‚‚ T β†’ HasType t₃ T β†’ HasType (ite t₁ tβ‚‚ t₃) T | t_0 : HasType zro nat | t_succ t₁ : HasType t₁ nat β†’ HasType (scc t₁) nat | t_pred t₁ : HasType t₁ nat β†’ HasType (prd t₁) nat | t_iszero t₁ : HasType t₁ nat β†’ HasType (iszero t₁) bool open HasType example -- `⊒ if false then 0 else (succ 0) ∈ nat` : HasType (ite fls zro (scc zro)) nat := by apply t_if . apply t_false . apply t_0 . apply t_succ apply t_0 /- It's important to realize that the typing relation is a _conservative_ (or _static_) approximation: it does not consider what happens when the term is reduced. In particular, it does not calculate the type of its normal form. -/ example -- `⊒ if false then zero else true βˆ‰ bool` : Β¬ HasType (ite fls zro tru) bool := by intro contra cases contra rename_i contra _ cases contra /- exercise (1-star) -/ example t : HasType (scc t) nat β†’ HasType t nat := by intro ht cases ht assumption
theorem progress t T : HasType t T β†’ value t ∨ βˆƒ t', Step t t' :=
:= by intro ht induction ht with | t_if t₁ tβ‚‚ t₃ T => rename_i ih₁ ihβ‚‚ ih₃ right; cases ih₁ . -- t₁ is a value have h : BValue t₁ := by apply bool_canonical <;> assumption cases h . exists tβ‚‚; apply st_ifTrue . exists t₃; apply st_ifFalse . -- t₁ can take a step rename_i h obtain ⟨t₁', hβ‚βŸ© := h exists ite t₁' tβ‚‚ t₃ apply st_if; exact h₁ | t_true => left;unfold value; left; apply bv_true | t_false => left; unfold value; left; apply bv_false | t_0 => left; unfold value; right; apply nv_0 | t_succ t => rename_i ih cases ih . -- t is a value left have h : NValue t := by apply nat_canonical <;> assumption cases h . unfold value; right; apply nv_succ; apply nv_0 . unfold value; right; apply nv_succ; apply nv_succ; assumption . -- t can take a step right rename_i ih obtain ⟨t', h⟩ := ih exists (scc t') apply st_succ; exact h | t_pred t => rename_i ih right; cases ih . -- t is a value have h : NValue t := by apply nat_canonical <;> assumption cases h . exists zro; apply st_pred0 . constructor; apply st_predSucc; assumption . -- t can take a step rename_i h obtain ⟨t', h⟩ := h exists (prd t') apply st_pred; exact h | t_iszero t => rename_i ih right; cases ih . -- t is a value have h : NValue t := by apply nat_canonical <;> assumption cases h . exists tru; apply st_iszero0 . exists fls; apply st_iszeroSucc; assumption . -- t can take a step rename_i h obtain ⟨t', h⟩ := h exists (iszero t') apply st_iszero; exact h /- ### Type preservation The second critical property of typing is that, when a well-typed term takes a step, the result is a well-typed term (of the same type). -/ /- exercise (3-star) Complete the following informal proof: _Theorem_: If `⊒ t ∈ T` and `t ~~> t'`, then `⊒ t' ∈ T`. _Proof_: By induction on a derivation of `⊒ t ∈ T`. * If the last rule in the derivation is `t_if`, then `t = if t₁ then tβ‚‚ else t₃`, with `⊒ t₁ ∈ bool`, `⊒ tβ‚‚ ∈ T`, and `⊒ t₃ ∈ T`. Inspecting the rules for the small-step reduction relation and remembering that `t` is the form `if ...`, we see that the only ones that could have been used to prove `t ~~> t'` are `st_ifTrue`, `st_ifFalse`, or `st_if`. * If the last rule was `st_ifTrue`, then `t' = tβ‚‚`. But we know that `⊒ tβ‚‚ ∈ T`, so we are done. * If the last rule was `st_ifFalse`, then `t' = t₃`. But we know that `⊒ t₃ ∈ T`, so we are done. * If the last rule was `st_if`, then `t' = if t₁' then tβ‚‚ else t₃`, where `t₁ ~~> t₁'`. We know `⊒ t₁ ∈ bool`, so by the IH, `⊒ t₁' ∈ bool`. The `t_if` rule then gives us `⊒ if if t₁' then tβ‚‚ else t₃ ∈ T`, as required. /- **FILL IN HERE** -/ -/
2
16
true
Semantics
272
Imp.fold_constants_com_sound
theorem fold_constants_com_sound : ctrans_sound fold_constants_com
lean-formal-reasoning-program
Frap/Trans.lean
[ "import Frap.Exercises.Equiv", "import Frap.Equiv" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "syntax \"<[\" term \"]>\" : imp", "content": "syntax \"<[\" term \"]>\" : imp\n\nsyntax \"<{\" imp \"}>\" : term\n\nsyntax \"false\" : imp\n\nsyntax \"false\" : term\n\nsyntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : imp\n\nsyntax \"true\" : imp\n\nsyntax \"true\" : term\n\nsyntax \"skip\" : imp\n\nsyntax:21 \"while\" imp:20 \"do\" imp:20 \"end\" : imp" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|true) => `(Bool.true)\n | `(term|false) => `(Bool.false)\n | `(term|<{$x}>) => `(imp|$x)\n | `(imp|$n:num) => `(a_num $n)\n | `(imp|$s:str) => `(a_id $s)\n | `(imp|$x + $y) => `(a_plus <{$x}> <{$y}>)\n | `(imp|$x - $y) => `(a_minus <{$x}> <{$y}>)\n | `(imp|$x * $y) => `(a_mult <{$x}> <{$y}>)\n | `(imp|true) => `(b_true)\n | `(imp|false) => `(b_false)\n | `(imp|$x = $y) => `(b_eq <{$x}> <{$y}>)\n | `(imp|$x != $y) => `(b_neq <{$x}> <{$y}>)\n | `(imp|$x <= $y) => `(b_le <{$x}> <{$y}>)\n | `(imp|!$x) => `(b_not <{$x}>)\n | `(imp|$x && $y) => `(b_and <{$x}> <{$y}>)\n | `(imp|$x || $y) => `(b_or <{$x}> <{$y}>)\n | `(imp|($x)) => `(<{$x}>)\n | `(imp|$x:ident) => `(a_id $(Lean.quote (toString x.getId)))\n | `(imp|<[$t:term]>) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(imp|skip) => `(c_skip)\n | `(imp|$x:str := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$x:ident := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$c1 ; $c2) => `(c_seq <{$c1}> <{$c2}>)\n | `(imp|if $b then $c1 else $c2 end) => `(c_if <{$b}> <{$c1}> <{$c2}>)\n | `(imp|while $b do $c end) => `(c_while <{$b}> <{$c}>)" }, { "name": "cequiv", "content": "def cequiv (c₁ cβ‚‚ : Com) : Prop :=\n βˆ€ st st' : State, (st =[<[c₁]>]=> st') ↔ (st =[<[cβ‚‚]>]=> st')" }, { "name": "State", "content": "abbrev State := String β†’ Nat" }, { "name": "Com", "content": "inductive Com :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_id : String β†’ AExp \n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "Com", "content": "inductive Com : Type :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com\n | c_par : Com β†’ Com β†’ Com " }, { "name": "BExp", "content": "inductive BExp where\n | b_true : BExp\n | b_false : BExp\n | b_eq : AExp β†’ AExp β†’ BExp\n | b_neq : AExp β†’ AExp β†’ BExp\n | b_le : AExp β†’ AExp β†’ BExp\n | b_not : BExp β†’ BExp\n | b_and : BExp β†’ BExp β†’ BExp\n | b_or : BExp β†’ BExp β†’ BExp" }, { "name": "x", "content": "abbrev x := \"x\"" }, { "name": "y", "content": "abbrev y := \"y\"" }, { "name": "loop", "content": "def loop : Com :=\n <{ while true do\n skip\n end }>" }, { "name": "bequiv", "content": "def bequiv (b₁ bβ‚‚ : BExp) : Prop :=\n βˆ€ (st : State), beval st b₁ = beval st bβ‚‚" }, { "name": "beval", "content": "def beval (st : State) (b : BExp) : Bool :=\n match b with\n | b_true => true\n | b_false => false\n | b_eq a₁ aβ‚‚ => (aeval st a₁) == (aeval st aβ‚‚)\n | b_neq a₁ aβ‚‚ => (aeval st a₁) != (aeval st aβ‚‚)\n | b_le a₁ aβ‚‚ => (aeval st a₁) <= (aeval st aβ‚‚)\n | b_not b₁ => not (beval st b₁)\n | b_and b₁ bβ‚‚ => and (beval st b₁) (beval st bβ‚‚)\n | b_or b₁ bβ‚‚ => or (beval st b₁) (beval st bβ‚‚)\n\nexample : aeval (update empty x 5)\n <{3 + x * 2}>\n \n = 13 := by admit /- proof elided -/" }, { "name": "empty", "content": "def empty : State := fun _ => 0" }, { "name": "z", "content": "abbrev z := \"z\"" }, { "name": "aeval", "content": "def aeval (st : State) (a : AExp) : Nat :=\n match a with\n | a_num n => n\n | a_id x => st x\n | a_plus a₁ aβ‚‚ => (aeval st a₁) + (aeval st aβ‚‚)\n | a_minus a₁ aβ‚‚ => (aeval st a₁) - (aeval st aβ‚‚)\n | a_mult a₁ aβ‚‚ => (aeval st a₁) * (aeval st aβ‚‚)" }, { "name": "update", "content": "def update (st : State) (k : String) (v : Nat) : State :=\n fun x => if x == k then v else st x" }, { "name": "aequiv", "content": "def aequiv (a₁ aβ‚‚ : AExp) : Prop :=\n βˆ€ (st : State), aeval st a₁ = aeval st aβ‚‚" }, { "name": "CEval", "content": "inductive CEval : Com β†’ State β†’ State β†’ Prop :=\n | e_skip : βˆ€ st,\n CEval c_skip st st\n | e_asgn : βˆ€ a n x st,\n aeval st a = n\n β†’ CEval (c_asgn x a) st (update st x n)\n | e_seq : βˆ€ c₁ cβ‚‚ st st' st'',\n CEval c₁ st st' β†’ CEval cβ‚‚ st' st''\n β†’ CEval (c_seq c₁ cβ‚‚) st st''\n | e_ifTrue : βˆ€ b c₁ cβ‚‚ st st',\n beval st b = true β†’ CEval c₁ st st'\n β†’ CEval (c_if b c₁ cβ‚‚) st st'\n | e_ifFalse : βˆ€ b c₁ cβ‚‚ st st',\n beval st b = false β†’ CEval cβ‚‚ st st'\n β†’ CEval (c_if b c₁ cβ‚‚) st st'\n | e_whileFalse : βˆ€ b c st,\n beval st b = false\n β†’ CEval (c_while b c) st st\n | e_whileTrue : βˆ€ b c st st' st'',\n beval st b = true\n β†’ CEval c st st'\n β†’ CEval (c_while b c) st' st''\n β†’ CEval (c_while b c) st st''" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "if_true", "content": "theorem if_true b c₁ cβ‚‚\n : bequiv b <{true}> β†’ cequiv <{if <[b]> then <[c₁]> else <[cβ‚‚]> end}> c₁" }, { "name": "if_false", "content": "theorem if_false b c₁ cβ‚‚\n : bequiv b <{false}> β†’ cequiv <{if <[b]> then <[c₁]> else <[cβ‚‚]> end}> cβ‚‚" }, { "name": "while_false", "content": "theorem while_false b c : bequiv b <{false}> β†’\n cequiv <{while <[b]> do <[c]> end}> <{skip}>" } ]
[ { "name": "Imp.atrans_sound", "content": "def atrans_sound (atrans : AExp β†’ AExp) :=\n βˆ€ (a : AExp), aequiv a (atrans a)" }, { "name": "Imp.btrans_sound", "content": "def btrans_sound (btrans : BExp β†’ BExp) :=\n βˆ€ (b : BExp), bequiv b (btrans b)" }, { "name": "Imp.ctrans_sound", "content": "def ctrans_sound (ctrans : Com β†’ Com) :=\n βˆ€ (c : Com), cequiv c (ctrans c)" }, { "name": "Imp.fold_constants_aexp", "content": "def fold_constants_aexp (a : AExp) : AExp :=\n match a with\n | a_num _\n | a_id _\n => a\n | a_plus a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => a_num (n1 + n2)\n | (a1', a2') => a_plus a1' a2'\n | a_minus a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => a_num (n1 - n2)\n | (a1', a2') => a_minus a1' a2'\n | a_mult a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => a_num (n1 * n2)\n | (a1', a2') => a_mult a1' a2'\n\nexample : fold_constants_aexp <{(1 + 2) * x}> = <{3 * x}> := by admit /- proof elided -/" }, { "name": "Imp.fold_constants_bexp", "content": "def fold_constants_bexp (b : BExp) : BExp :=\n match b with\n | b_true\n | b_false\n => b\n | b_eq a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => if n1 == n2 then b_true else b_false\n | (a1', a2') => b_eq a1' a2'\n | b_neq a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => if n1 != n2 then b_true else b_false\n | (a1', a2') => b_neq a1' a2'\n | b_le a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => if n1 <= n2 then b_true else b_false\n | (a1', a2') => b_le a1' a2'\n | b_not b1 =>\n match fold_constants_bexp b1 with\n | b_true => b_false\n | b_false => b_true\n | b1' => b_not b1'\n | b_and b1 b2 =>\n match (fold_constants_bexp b1, fold_constants_bexp b2) with\n | (b_true, b_true) => b_true\n | (b_true, b_false) => b_false\n | (b_false, b_true) => b_false\n | (b_false, b_false) => b_false\n | (b1', b2') => b_and b1' b2'\n | b_or b1 b2 =>\n match (fold_constants_bexp b1, fold_constants_bexp b2) with\n | (b_true, b_true) => b_true\n | (b_true, b_false) => b_true\n | (b_false, b_true) => b_true\n | (b_false, b_false) => b_false\n | (b1', b2') => b_or b1' b2'\n\nexample : fold_constants_bexp <{true && !(false && true)}> = <{true}> := by admit /- proof elided -/" }, { "name": "Imp.fold_constants_com", "content": "def fold_constants_com (c : Com) : Com :=\n match c with\n | c_skip => c\n | c_asgn x a => c_asgn x (fold_constants_aexp a)\n | c_seq c1 c2 => c_seq (fold_constants_com c1) (fold_constants_com c2)\n | c_if b c1 c2 =>\n match fold_constants_bexp b with\n | b_true => fold_constants_com c1\n | b_false => fold_constants_com c2\n | b' => c_if b' (fold_constants_com c1) (fold_constants_com c2)\n | c_while b c1 =>\n match fold_constants_bexp b with\n | b_true => loop\n | b_false => c_skip\n | b' => c_while b' (fold_constants_com c1)\n\nexample : fold_constants_com\n \n <{ x := 4 + 5;\n y := x - 3;\n if (x - y) = (2 + 4) then skip\n else y := 0 end;\n if 0 <= (4 - (2 + 1)) then y := 0\n else skip end;\n while y = 0 do\n x := x + 1\n end }>\n = \n <{ x := 9;\n y := x - 3;\n if (x - y) = 6 then skip\n else y := 0 end;\n y := 0;\n while y = 0 do\n x := x + 1\n end }> := by admit /- proof elided -/" } ]
[ { "name": "Imp.while_true", "content": "theorem while_true b c :\n bequiv b <{true}> β†’ cequiv <{while <[b]> do <[c]> end}> loop" }, { "name": "Imp.sym_bequiv", "content": "theorem sym_bequiv b₁ bβ‚‚ : bequiv b₁ bβ‚‚ β†’ bequiv bβ‚‚ b₁" }, { "name": "Imp.sym_cequiv", "content": "theorem sym_cequiv c₁ cβ‚‚ : cequiv c₁ cβ‚‚ β†’ cequiv cβ‚‚ c₁" }, { "name": "Imp.trans_cequiv", "content": "theorem trans_cequiv c₁ cβ‚‚ c₃ : cequiv c₁ cβ‚‚ β†’ cequiv cβ‚‚ c₃ β†’ cequiv c₁ c₃" }, { "name": "Imp.c_asgn_congruence", "content": "theorem c_asgn_congruence x a a'\n : aequiv a a' β†’ cequiv <{x := <[a]>}> <{x := <[a']>}>" }, { "name": "Imp.c_while_congruence", "content": "theorem c_while_congruence b b' c c'\n : bequiv b b' β†’ cequiv c c'\n β†’ cequiv <{while <[b]> do <[c]> end}> <{while <[b']> do <[c']> end}>" }, { "name": "Imp.c_seq_congruence", "content": "theorem c_seq_congruence c₁ c₁' cβ‚‚ cβ‚‚'\n : cequiv c₁ c₁' β†’ cequiv cβ‚‚ cβ‚‚' β†’ cequiv (c_seq c₁ cβ‚‚) (c_seq c₁' cβ‚‚')" }, { "name": "Imp.c_if_congruence", "content": "theorem c_if_congruence b b' c₁ c₁' cβ‚‚ cβ‚‚'\n : bequiv b b' β†’ cequiv c₁ c₁' β†’ cequiv cβ‚‚ cβ‚‚'\n β†’ cequiv (c_if b c₁ cβ‚‚) (c_if b' c₁' cβ‚‚')" }, { "name": "Imp.fold_constants_aexp_sound", "content": "theorem fold_constants_aexp_sound : atrans_sound fold_constants_aexp" }, { "name": "Imp.fold_constants_bexp_sound", "content": "theorem fold_constants_bexp_sound : btrans_sound fold_constants_bexp" } ]
import Frap.Equiv import Frap.Exercises.Equiv namespace Imp open AExp open BExp open Com open CEval def atrans_sound (atrans : AExp β†’ AExp) := βˆ€ (a : AExp), aequiv a (atrans a) def btrans_sound (btrans : BExp β†’ BExp) := βˆ€ (b : BExp), bequiv b (btrans b) def ctrans_sound (ctrans : Com β†’ Com) := βˆ€ (c : Com), cequiv c (ctrans c) def fold_constants_aexp (a : AExp) : AExp := match a with | a_num _ | a_id _ => a | a_plus a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => a_num (n1 + n2) | (a1', a2') => a_plus a1' a2' | a_minus a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => a_num (n1 - n2) | (a1', a2') => a_minus a1' a2' | a_mult a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => a_num (n1 * n2) | (a1', a2') => a_mult a1' a2' example : fold_constants_aexp <{(1 + 2) * x}> = <{3 * x}> := by admit /- proof elided -/ def fold_constants_bexp (b : BExp) : BExp := match b with | b_true | b_false => b | b_eq a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => if n1 == n2 then b_true else b_false | (a1', a2') => b_eq a1' a2' | b_neq a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => if n1 != n2 then b_true else b_false | (a1', a2') => b_neq a1' a2' | b_le a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => if n1 <= n2 then b_true else b_false | (a1', a2') => b_le a1' a2' | b_not b1 => match fold_constants_bexp b1 with | b_true => b_false | b_false => b_true | b1' => b_not b1' | b_and b1 b2 => match (fold_constants_bexp b1, fold_constants_bexp b2) with | (b_true, b_true) => b_true | (b_true, b_false) => b_false | (b_false, b_true) => b_false | (b_false, b_false) => b_false | (b1', b2') => b_and b1' b2' | b_or b1 b2 => match (fold_constants_bexp b1, fold_constants_bexp b2) with | (b_true, b_true) => b_true | (b_true, b_false) => b_true | (b_false, b_true) => b_true | (b_false, b_false) => b_false | (b1', b2') => b_or b1' b2' example : fold_constants_bexp <{true && !(false && true)}> = <{true}> := by admit /- proof elided -/ def fold_constants_com (c : Com) : Com := match c with | c_skip => c | c_asgn x a => c_asgn x (fold_constants_aexp a) | c_seq c1 c2 => c_seq (fold_constants_com c1) (fold_constants_com c2) | c_if b c1 c2 => match fold_constants_bexp b with | b_true => fold_constants_com c1 | b_false => fold_constants_com c2 | b' => c_if b' (fold_constants_com c1) (fold_constants_com c2) | c_while b c1 => match fold_constants_bexp b with | b_true => loop | b_false => c_skip | b' => c_while b' (fold_constants_com c1) example : fold_constants_com <{ x := 4 + 5; y := x - 3; if (x - y) = (2 + 4) then skip else y := 0 end; if 0 <= (4 - (2 + 1)) then y := 0 else skip end; while y = 0 do x := x + 1 end }> = <{ x := 9; y := x - 3; if (x - y) = 6 then skip else y := 0 end; y := 0; while y = 0 do x := x + 1 end }> := by admit /- proof elided -/
theorem fold_constants_com_sound : ctrans_sound fold_constants_com :=
:= by intro c; induction c with simp [fold_constants_com] | c_asgn => apply c_asgn_congruence apply fold_constants_aexp_sound | c_seq => apply c_seq_congruence <;> assumption | c_if b c₁ cβ‚‚ ih1 ih2 => split . apply trans_cequiv _ c₁ . apply if_true rename_i heq; rw [← heq] apply fold_constants_bexp_sound . assumption . apply trans_cequiv _ cβ‚‚ . apply if_false rename_i heq; rw [← heq] apply fold_constants_bexp_sound . assumption . apply c_if_congruence . apply fold_constants_bexp_sound . assumption . assumption | c_while b c' ih => split . apply while_true rename_i heq; rw [← heq] apply fold_constants_bexp_sound . apply while_false rename_i heq; rw [← heq] apply fold_constants_bexp_sound . apply c_while_congruence . apply fold_constants_bexp_sound . assumption
5
40
true
Semantics
273
CImp.par_loop_any_x
theorem par_loop_any_x n : βˆƒ st', Multi CStep (par_loop, empty) (c_skip, st') ∧ st' x = n
lean-formal-reasoning-program
Frap/SmallStepImp.lean
[ "import Frap.SmallStep", "import Frap.Equiv" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" }, { "name": "And", "module": "Init.Prelude" } ]
[ { "name": "syntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : im", "content": "syntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : imp" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|true) => `(Bool.true)\n | `(term|false) => `(Bool.false)\n | `(term|<{$x}>) => `(imp|$x)\n | `(imp|$n:num) => `(a_num $n)\n | `(imp|$s:str) => `(a_id $s)\n | `(imp|$x + $y) => `(a_plus <{$x}> <{$y}>)\n | `(imp|$x - $y) => `(a_minus <{$x}> <{$y}>)\n | `(imp|$x * $y) => `(a_mult <{$x}> <{$y}>)\n | `(imp|true) => `(b_true)\n | `(imp|false) => `(b_false)\n | `(imp|$x = $y) => `(b_eq <{$x}> <{$y}>)\n | `(imp|$x != $y) => `(b_neq <{$x}> <{$y}>)\n | `(imp|$x <= $y) => `(b_le <{$x}> <{$y}>)\n | `(imp|!$x) => `(b_not <{$x}>)\n | `(imp|$x && $y) => `(b_and <{$x}> <{$y}>)\n | `(imp|$x || $y) => `(b_or <{$x}> <{$y}>)\n | `(imp|($x)) => `(<{$x}>)\n | `(imp|$x:ident) => `(a_id $(Lean.quote (toString x.getId)))\n | `(imp|<[$t:term]>) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(imp|skip) => `(c_skip)\n | `(imp|$x:str := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$x:ident := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$c1 ; $c2) => `(c_seq <{$c1}> <{$c2}>)\n | `(imp|if $b then $c1 else $c2 end) => `(c_if <{$b}> <{$c1}> <{$c2}>)\n | `(imp|while $b do $c end) => `(c_while <{$b}> <{$c}>)" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_id : String β†’ AExp \n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "State", "content": "abbrev State := String β†’ Nat" }, { "name": "BExp", "content": "inductive BExp where\n | b_true : BExp\n | b_false : BExp\n | b_eq : AExp β†’ AExp β†’ BExp\n | b_neq : AExp β†’ AExp β†’ BExp\n | b_le : AExp β†’ AExp β†’ BExp\n | b_not : BExp β†’ BExp\n | b_and : BExp β†’ BExp β†’ BExp\n | b_or : BExp β†’ BExp β†’ BExp" }, { "name": "x", "content": "abbrev x := \"x\"" }, { "name": "Com", "content": "inductive Com :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com" }, { "name": "empty", "content": "def empty : State := fun _ => 0" }, { "name": "Multi", "content": "inductive Multi {X : Type} (R : relation X) : relation X :=\n | multi_refl x : Multi R x x\n | multi_step x y z : R x y β†’ Multi R y z β†’ Multi R x z" }, { "name": "relation", "content": "def relation (X : Type) := X β†’ X β†’ Prop" }, { "name": "update", "content": "def update (st : State) (k : String) (v : Nat) : State :=\n fun x => if x == k then v else st x" }, { "name": "y", "content": "abbrev y := \"y\"" }, { "name": "And", "content": "inductive And : Prop β†’ Prop β†’ Prop where\n | intro : a β†’ b β†’ And a b" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "multi_R", "content": "theorem multi_R (X : Type) (R : relation X) x y : R x y β†’ Multi R x y" }, { "name": "multi_trans", "content": "theorem multi_trans (X : Type) (R : relation X) x y z\n : Multi R x y β†’ Multi R y z β†’ Multi R x z" } ]
[ { "name": "AVal", "content": "inductive AVal : AExp β†’ Prop :=\n | av_num : βˆ€ n, AVal (a_num n)" }, { "name": "AStep", "content": "inductive AStep (st : State) : AExp β†’ AExp β†’ Prop :=\n | as_id : βˆ€ v, AStep st (a_id v) (a_num (st v))\n | as_plus1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ AStep st (a_plus a₁ aβ‚‚) (a_plus a₁' aβ‚‚)\n | as_plus2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ AStep st (a_plus v₁ aβ‚‚) (a_plus v₁ aβ‚‚')\n | as_plus : βˆ€ (v₁ vβ‚‚ : Nat),\n AStep st (a_plus (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ + vβ‚‚))\n | as_minus1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ AStep st (a_minus a₁ aβ‚‚) (a_minus a₁' aβ‚‚)\n | as_minus2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ AStep st (a_minus v₁ aβ‚‚) (a_minus v₁ aβ‚‚')\n | as_minus : βˆ€ (v₁ vβ‚‚ : Nat),\n AStep st (a_minus (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ - vβ‚‚))\n | as_mult1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ AStep st (a_mult a₁ aβ‚‚) (a_mult a₁' aβ‚‚)\n | as_mult2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ AStep st (a_mult v₁ aβ‚‚) (a_mult v₁ aβ‚‚')\n | as_mult : βˆ€ (v₁ vβ‚‚ : Nat),\n AStep st (a_mult (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ * vβ‚‚))" }, { "name": "BStep", "content": "inductive BStep (st : State) : BExp β†’ BExp β†’ Prop :=\n | bs_eq1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ BStep st (b_eq a₁ aβ‚‚) (b_eq a₁' aβ‚‚)\n | bs_eq2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ BStep st (b_eq v₁ aβ‚‚) (b_eq v₁ aβ‚‚')\n | bs_eq : βˆ€ (v₁ vβ‚‚ : Nat),\n BStep st (b_eq (a_num v₁) (a_num vβ‚‚))\n (if v₁ == vβ‚‚ then b_true else b_false)\n | bs_neq1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ BStep st (b_neq a₁ aβ‚‚) (b_neq a₁' aβ‚‚)\n | bs_neq2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ BStep st (b_neq v₁ aβ‚‚) (b_neq v₁ aβ‚‚')\n | bs_neq : βˆ€ (v₁ vβ‚‚ : Nat),\n BStep st (b_neq (a_num v₁) (a_num vβ‚‚))\n (if v₁ != vβ‚‚ then b_true else b_false)\n | bs_le1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ BStep st (b_le a₁ aβ‚‚) (b_le a₁' aβ‚‚)\n | bs_le2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ BStep st (b_le v₁ aβ‚‚) (b_le v₁ aβ‚‚')\n | bs_le : βˆ€ (v₁ vβ‚‚ : Nat),\n BStep st (b_le (a_num v₁) (a_num vβ‚‚))\n (if v₁ <= vβ‚‚ then b_true else b_false)\n | bs_notStep : βˆ€ b₁ b₁',\n BStep st b₁ b₁'\n β†’ BStep st (b_not b₁) (b_not b₁')\n | bs_notTrue : BStep st (b_not b_true) b_false\n | bs_notFalse : BStep st (b_not b_false) b_true\n | bs_andStep : βˆ€ b₁ b₁' bβ‚‚,\n BStep st b₁ b₁'\n β†’ BStep st (b_and b₁ bβ‚‚) (b_and b₁' bβ‚‚)\n | bs_andFalse : βˆ€ bβ‚‚,\n BStep st (b_and b_false bβ‚‚) b_false\n | bs_andTrueStep : βˆ€ bβ‚‚ bβ‚‚',\n BStep st bβ‚‚ bβ‚‚'\n β†’ BStep st (b_and b_true bβ‚‚) (b_and b_true bβ‚‚')\n | bs_andTrueTrue :\n BStep st (b_and b_true b_true) b_true\n | bs_andTrueFalse :\n BStep st (b_and b_true b_false) b_false\n | bs_orStep : βˆ€ b₁ b₁' bβ‚‚,\n BStep st b₁ b₁'\n β†’ BStep st (b_or b₁ bβ‚‚) (b_or b₁' bβ‚‚)\n | bs_orTrue : βˆ€ bβ‚‚,\n BStep st (b_or b_true bβ‚‚) b_true\n | bs_orFalseStep : βˆ€ bβ‚‚ bβ‚‚',\n BStep st bβ‚‚ bβ‚‚'\n β†’ BStep st (b_or b_false bβ‚‚) (b_or b_false bβ‚‚')\n | bs_orFalseTrue :\n BStep st (b_or b_false b_true) b_true\n | bs_orFalseFalse :\n BStep st (b_or b_false b_false) b_false" }, { "name": "CStep", "content": "inductive CStep : (Com Γ— State) β†’ (Com Γ— State) β†’ Prop :=\n | cs_asgnStep : βˆ€ st v a₁ a₁',\n AStep st a₁ a₁'\n β†’ CStep (c_asgn v a₁, st) (c_asgn v a₁', st)\n | cs_asgn : βˆ€ st v (n : Nat),\n CStep (c_asgn v (a_num n), st) (c_skip, x !-> n; st)\n | cs_seqStep : βˆ€ st c₁ c₁' st' cβ‚‚,\n CStep (c₁, st) (c₁', st')\n β†’ CStep (c_seq c₁ cβ‚‚, st) (c_seq c₁' cβ‚‚, st')\n | cs_seqFinish : βˆ€ st cβ‚‚,\n CStep (c_seq c_skip cβ‚‚, st) (cβ‚‚, st)\n | cs_ifStep : βˆ€ st b₁ b₁' c₁ cβ‚‚,\n BStep st b₁ b₁'\n β†’ CStep (c_if b₁ c₁ cβ‚‚, st) (c_if b₁' c₁ cβ‚‚, st)\n | cs_ifTrue : βˆ€ st c₁ cβ‚‚,\n CStep (c_if b_true c₁ cβ‚‚, st) (c₁, st)\n | cs_ifFalse : βˆ€ st c₁ cβ‚‚,\n CStep (c_if b_false c₁ cβ‚‚, st) (cβ‚‚, st)\n | cs_while : βˆ€ st b₁ c₁,\n CStep (c_while b₁ c₁, st)\n (c_if b₁ (c_seq c₁ (c_while b₁ c₁)) c_skip, st)" }, { "name": "CImp.Com", "content": "inductive Com : Type :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com\n | c_par : Com β†’ Com β†’ Com" }, { "name": "CImp.CStep", "content": "inductive CStep : (Com Γ— State) β†’ (Com Γ— State) β†’ Prop :=\n \n | cs_asgnStep : βˆ€ st v a₁ a₁',\n AStep st a₁ a₁'\n β†’ CStep (c_asgn v a₁, st) (c_asgn v a₁', st)\n | cs_asgn : βˆ€ st v (n : Nat),\n CStep (c_asgn v (a_num n), st) (c_skip, v !-> n; st)\n | cs_seqStep : βˆ€ st c₁ c₁' st' cβ‚‚,\n CStep (c₁, st) (c₁', st')\n β†’ CStep (c_seq c₁ cβ‚‚, st) (c_seq c₁' cβ‚‚, st')\n | cs_seqFinish : βˆ€ st cβ‚‚,\n CStep (c_seq c_skip cβ‚‚, st) (cβ‚‚, st)\n | cs_ifStep : βˆ€ st b₁ b₁' c₁ cβ‚‚,\n BStep st b₁ b₁'\n β†’ CStep (c_if b₁ c₁ cβ‚‚, st) (c_if b₁' c₁ cβ‚‚, st)\n | cs_ifTrue : βˆ€ st c₁ cβ‚‚,\n CStep (c_if b_true c₁ cβ‚‚, st) (c₁, st)\n | cs_ifFalse : βˆ€ st c₁ cβ‚‚,\n CStep (c_if b_false c₁ cβ‚‚, st) (cβ‚‚, st)\n | cs_while : βˆ€ st b₁ c₁,\n CStep (c_while b₁ c₁, st)\n (c_if b₁ (c_seq c₁ (c_while b₁ c₁)) c_skip, st)\n \n | cs_par1 : βˆ€ st c₁ c₁' cβ‚‚ st',\n CStep (c₁, st) (c₁', st')\n β†’ CStep (c_par c₁ cβ‚‚, st) (c_par c₁' cβ‚‚, st')\n | cs_par2 : βˆ€ st c₁ cβ‚‚ cβ‚‚' st',\n CStep (cβ‚‚, st) (cβ‚‚', st')\n β†’ CStep (c_par c₁ cβ‚‚, st) (c_par c₁ cβ‚‚', st')\n | cs_parDone : βˆ€ st,\n CStep (c_par c_skip c_skip, st) (c_skip, st)" }, { "name": "CImp.par_loop", "content": "def par_loop : Com :=\n c_par\n (c_asgn y (a_num 1))\n (c_while (b_eq (a_id y) (a_num 0))\n (c_asgn x (a_plus (a_id x) (a_num 1))))\n\n/-\nIn particular, it can terminate with `x` set to `0`.\n-/\n\nexample : βˆƒ st',\n Multi CStep (par_loop, empty) (c_skip, st')\n ∧ st' x = 0 :=" } ]
[ { "name": "CImp.par_body_n__Sn", "content": "theorem par_body_n__Sn n st\n : st x = n ∧ st y = 0\n β†’ Multi CStep (par_loop, st) (par_loop, x !-> n + 1; st)" }, { "name": "CImp.par_body_n", "content": "theorem par_body_n n st\n : st x = 0 ∧ st y = 0\n β†’ βˆƒ st', Multi CStep (par_loop, st) (par_loop, st')\n ∧ st' x = n ∧ st' y = 0" } ]
import Frap.Equiv import Frap.SmallStep open Imp open AExp open BExp open Com open Multi inductive AVal : AExp β†’ Prop := | av_num : βˆ€ n, AVal (a_num n) inductive AStep (st : State) : AExp β†’ AExp β†’ Prop := | as_id : βˆ€ v, AStep st (a_id v) (a_num (st v)) | as_plus1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ AStep st (a_plus a₁ aβ‚‚) (a_plus a₁' aβ‚‚) | as_plus2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ AStep st (a_plus v₁ aβ‚‚) (a_plus v₁ aβ‚‚') | as_plus : βˆ€ (v₁ vβ‚‚ : Nat), AStep st (a_plus (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ + vβ‚‚)) | as_minus1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ AStep st (a_minus a₁ aβ‚‚) (a_minus a₁' aβ‚‚) | as_minus2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ AStep st (a_minus v₁ aβ‚‚) (a_minus v₁ aβ‚‚') | as_minus : βˆ€ (v₁ vβ‚‚ : Nat), AStep st (a_minus (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ - vβ‚‚)) | as_mult1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ AStep st (a_mult a₁ aβ‚‚) (a_mult a₁' aβ‚‚) | as_mult2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ AStep st (a_mult v₁ aβ‚‚) (a_mult v₁ aβ‚‚') | as_mult : βˆ€ (v₁ vβ‚‚ : Nat), AStep st (a_mult (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ * vβ‚‚)) open AStep inductive BStep (st : State) : BExp β†’ BExp β†’ Prop := | bs_eq1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ BStep st (b_eq a₁ aβ‚‚) (b_eq a₁' aβ‚‚) | bs_eq2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ BStep st (b_eq v₁ aβ‚‚) (b_eq v₁ aβ‚‚') | bs_eq : βˆ€ (v₁ vβ‚‚ : Nat), BStep st (b_eq (a_num v₁) (a_num vβ‚‚)) (if v₁ == vβ‚‚ then b_true else b_false) | bs_neq1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ BStep st (b_neq a₁ aβ‚‚) (b_neq a₁' aβ‚‚) | bs_neq2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ BStep st (b_neq v₁ aβ‚‚) (b_neq v₁ aβ‚‚') | bs_neq : βˆ€ (v₁ vβ‚‚ : Nat), BStep st (b_neq (a_num v₁) (a_num vβ‚‚)) (if v₁ != vβ‚‚ then b_true else b_false) | bs_le1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ BStep st (b_le a₁ aβ‚‚) (b_le a₁' aβ‚‚) | bs_le2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ BStep st (b_le v₁ aβ‚‚) (b_le v₁ aβ‚‚') | bs_le : βˆ€ (v₁ vβ‚‚ : Nat), BStep st (b_le (a_num v₁) (a_num vβ‚‚)) (if v₁ <= vβ‚‚ then b_true else b_false) | bs_notStep : βˆ€ b₁ b₁', BStep st b₁ b₁' β†’ BStep st (b_not b₁) (b_not b₁') | bs_notTrue : BStep st (b_not b_true) b_false | bs_notFalse : BStep st (b_not b_false) b_true | bs_andStep : βˆ€ b₁ b₁' bβ‚‚, BStep st b₁ b₁' β†’ BStep st (b_and b₁ bβ‚‚) (b_and b₁' bβ‚‚) | bs_andFalse : βˆ€ bβ‚‚, BStep st (b_and b_false bβ‚‚) b_false | bs_andTrueStep : βˆ€ bβ‚‚ bβ‚‚', BStep st bβ‚‚ bβ‚‚' β†’ BStep st (b_and b_true bβ‚‚) (b_and b_true bβ‚‚') | bs_andTrueTrue : BStep st (b_and b_true b_true) b_true | bs_andTrueFalse : BStep st (b_and b_true b_false) b_false | bs_orStep : βˆ€ b₁ b₁' bβ‚‚, BStep st b₁ b₁' β†’ BStep st (b_or b₁ bβ‚‚) (b_or b₁' bβ‚‚) | bs_orTrue : βˆ€ bβ‚‚, BStep st (b_or b_true bβ‚‚) b_true | bs_orFalseStep : βˆ€ bβ‚‚ bβ‚‚', BStep st bβ‚‚ bβ‚‚' β†’ BStep st (b_or b_false bβ‚‚) (b_or b_false bβ‚‚') | bs_orFalseTrue : BStep st (b_or b_false b_true) b_true | bs_orFalseFalse : BStep st (b_or b_false b_false) b_false open BStep inductive CStep : (Com Γ— State) β†’ (Com Γ— State) β†’ Prop := | cs_asgnStep : βˆ€ st v a₁ a₁', AStep st a₁ a₁' β†’ CStep (c_asgn v a₁, st) (c_asgn v a₁', st) | cs_asgn : βˆ€ st v (n : Nat), CStep (c_asgn v (a_num n), st) (c_skip, x !-> n; st) | cs_seqStep : βˆ€ st c₁ c₁' st' cβ‚‚, CStep (c₁, st) (c₁', st') β†’ CStep (c_seq c₁ cβ‚‚, st) (c_seq c₁' cβ‚‚, st') | cs_seqFinish : βˆ€ st cβ‚‚, CStep (c_seq c_skip cβ‚‚, st) (cβ‚‚, st) | cs_ifStep : βˆ€ st b₁ b₁' c₁ cβ‚‚, BStep st b₁ b₁' β†’ CStep (c_if b₁ c₁ cβ‚‚, st) (c_if b₁' c₁ cβ‚‚, st) | cs_ifTrue : βˆ€ st c₁ cβ‚‚, CStep (c_if b_true c₁ cβ‚‚, st) (c₁, st) | cs_ifFalse : βˆ€ st c₁ cβ‚‚, CStep (c_if b_false c₁ cβ‚‚, st) (cβ‚‚, st) | cs_while : βˆ€ st b₁ c₁, CStep (c_while b₁ c₁, st) (c_if b₁ (c_seq c₁ (c_while b₁ c₁)) c_skip, st) namespace CImp inductive Com : Type := | c_skip : Com | c_asgn : String β†’ AExp β†’ Com | c_seq : Com β†’ Com β†’ Com | c_if : BExp β†’ Com β†’ Com β†’ Com | c_while : BExp β†’ Com β†’ Com | c_par : Com β†’ Com β†’ Com open Com inductive CStep : (Com Γ— State) β†’ (Com Γ— State) β†’ Prop := | cs_asgnStep : βˆ€ st v a₁ a₁', AStep st a₁ a₁' β†’ CStep (c_asgn v a₁, st) (c_asgn v a₁', st) | cs_asgn : βˆ€ st v (n : Nat), CStep (c_asgn v (a_num n), st) (c_skip, v !-> n; st) | cs_seqStep : βˆ€ st c₁ c₁' st' cβ‚‚, CStep (c₁, st) (c₁', st') β†’ CStep (c_seq c₁ cβ‚‚, st) (c_seq c₁' cβ‚‚, st') | cs_seqFinish : βˆ€ st cβ‚‚, CStep (c_seq c_skip cβ‚‚, st) (cβ‚‚, st) | cs_ifStep : βˆ€ st b₁ b₁' c₁ cβ‚‚, BStep st b₁ b₁' β†’ CStep (c_if b₁ c₁ cβ‚‚, st) (c_if b₁' c₁ cβ‚‚, st) | cs_ifTrue : βˆ€ st c₁ cβ‚‚, CStep (c_if b_true c₁ cβ‚‚, st) (c₁, st) | cs_ifFalse : βˆ€ st c₁ cβ‚‚, CStep (c_if b_false c₁ cβ‚‚, st) (cβ‚‚, st) | cs_while : βˆ€ st b₁ c₁, CStep (c_while b₁ c₁, st) (c_if b₁ (c_seq c₁ (c_while b₁ c₁)) c_skip, st) | cs_par1 : βˆ€ st c₁ c₁' cβ‚‚ st', CStep (c₁, st) (c₁', st') β†’ CStep (c_par c₁ cβ‚‚, st) (c_par c₁' cβ‚‚, st') | cs_par2 : βˆ€ st c₁ cβ‚‚ cβ‚‚' st', CStep (cβ‚‚, st) (cβ‚‚', st') β†’ CStep (c_par c₁ cβ‚‚, st) (c_par c₁ cβ‚‚', st') | cs_parDone : βˆ€ st, CStep (c_par c_skip c_skip, st) (c_skip, st) open CStep def par_loop : Com := c_par (c_asgn y (a_num 1)) (c_while (b_eq (a_id y) (a_num 0)) (c_asgn x (a_plus (a_id x) (a_num 1)))) /- In particular, it can terminate with `x` set to `0`. -/ example : βˆƒ st', Multi CStep (par_loop, empty) (c_skip, st') ∧ st' x = 0 :=
theorem par_loop_any_x n : βˆƒ st', Multi CStep (par_loop, empty) (c_skip, st') ∧ st' x = n :=
:= by let h := par_body_n n empty simp [empty] at h obtain ⟨st', ⟨h', ⟨hx, _⟩⟩⟩ := h exists y !-> 1; st' constructor . apply multi_trans . apply h' . apply multi_step . apply cs_par1; apply cs_asgn . apply multi_step . apply cs_par2; apply cs_while . apply multi_step . apply cs_par2; apply cs_ifStep apply bs_eq1; apply as_id . apply multi_step . apply cs_par2; apply cs_ifStep apply bs_eq . simp [update]; apply multi_step . apply cs_par2; apply cs_ifFalse . apply multi_R apply cs_parDone . simp [update]; assumption
3
27
true
Semantics
274
Imp.fold_constants_bexp_sound
theorem fold_constants_bexp_sound : btrans_sound fold_constants_bexp
lean-formal-reasoning-program
Frap/Trans.lean
[ "import Frap.Exercises.Equiv", "import Frap.Equiv" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "syntax \"<{\" imp \"}>\" : term", "content": "syntax \"<{\" imp \"}>\" : term\n\nsyntax \"false\" : imp\n\nsyntax \"false\" : term\n\nsyntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : imp\n\nsyntax \"true\" : imp\n\nsyntax \"true\" : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|true) => `(Bool.true)\n | `(term|false) => `(Bool.false)\n | `(term|<{$x}>) => `(imp|$x)\n | `(imp|$n:num) => `(a_num $n)\n | `(imp|$s:str) => `(a_id $s)\n | `(imp|$x + $y) => `(a_plus <{$x}> <{$y}>)\n | `(imp|$x - $y) => `(a_minus <{$x}> <{$y}>)\n | `(imp|$x * $y) => `(a_mult <{$x}> <{$y}>)\n | `(imp|true) => `(b_true)\n | `(imp|false) => `(b_false)\n | `(imp|$x = $y) => `(b_eq <{$x}> <{$y}>)\n | `(imp|$x != $y) => `(b_neq <{$x}> <{$y}>)\n | `(imp|$x <= $y) => `(b_le <{$x}> <{$y}>)\n | `(imp|!$x) => `(b_not <{$x}>)\n | `(imp|$x && $y) => `(b_and <{$x}> <{$y}>)\n | `(imp|$x || $y) => `(b_or <{$x}> <{$y}>)\n | `(imp|($x)) => `(<{$x}>)\n | `(imp|$x:ident) => `(a_id $(Lean.quote (toString x.getId)))\n | `(imp|<[$t:term]>) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(imp|skip) => `(c_skip)\n | `(imp|$x:str := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$x:ident := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$c1 ; $c2) => `(c_seq <{$c1}> <{$c2}>)\n | `(imp|if $b then $c1 else $c2 end) => `(c_if <{$b}> <{$c1}> <{$c2}>)\n | `(imp|while $b do $c end) => `(c_while <{$b}> <{$c}>)" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_id : String β†’ AExp \n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "x", "content": "abbrev x := \"x\"" }, { "name": "y", "content": "abbrev y := \"y\"" }, { "name": "BExp", "content": "inductive BExp where\n | b_true : BExp\n | b_false : BExp\n | b_eq : AExp β†’ AExp β†’ BExp\n | b_neq : AExp β†’ AExp β†’ BExp\n | b_le : AExp β†’ AExp β†’ BExp\n | b_not : BExp β†’ BExp\n | b_and : BExp β†’ BExp β†’ BExp\n | b_or : BExp β†’ BExp β†’ BExp" }, { "name": "bequiv", "content": "def bequiv (b₁ bβ‚‚ : BExp) : Prop :=\n βˆ€ (st : State), beval st b₁ = beval st bβ‚‚" }, { "name": "beval", "content": "def beval (st : State) (b : BExp) : Bool :=\n match b with\n | b_true => true\n | b_false => false\n | b_eq a₁ aβ‚‚ => (aeval st a₁) == (aeval st aβ‚‚)\n | b_neq a₁ aβ‚‚ => (aeval st a₁) != (aeval st aβ‚‚)\n | b_le a₁ aβ‚‚ => (aeval st a₁) <= (aeval st aβ‚‚)\n | b_not b₁ => not (beval st b₁)\n | b_and b₁ bβ‚‚ => and (beval st b₁) (beval st bβ‚‚)\n | b_or b₁ bβ‚‚ => or (beval st b₁) (beval st bβ‚‚)\n\nexample : aeval (update empty x 5)\n <{3 + x * 2}>\n \n = 13 := by admit /- proof elided -/" }, { "name": "empty", "content": "def empty : State := fun _ => 0" }, { "name": "State", "content": "abbrev State := String β†’ Nat" }, { "name": "z", "content": "abbrev z := \"z\"" }, { "name": "aeval", "content": "def aeval (st : State) (a : AExp) : Nat :=\n match a with\n | a_num n => n\n | a_id x => st x\n | a_plus a₁ aβ‚‚ => (aeval st a₁) + (aeval st aβ‚‚)\n | a_minus a₁ aβ‚‚ => (aeval st a₁) - (aeval st aβ‚‚)\n | a_mult a₁ aβ‚‚ => (aeval st a₁) * (aeval st aβ‚‚)" }, { "name": "update", "content": "def update (st : State) (k : String) (v : Nat) : State :=\n fun x => if x == k then v else st x" }, { "name": "aequiv", "content": "def aequiv (a₁ aβ‚‚ : AExp) : Prop :=\n βˆ€ (st : State), aeval st a₁ = aeval st aβ‚‚" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Imp.atrans_sound", "content": "def atrans_sound (atrans : AExp β†’ AExp) :=\n βˆ€ (a : AExp), aequiv a (atrans a)" }, { "name": "Imp.btrans_sound", "content": "def btrans_sound (btrans : BExp β†’ BExp) :=\n βˆ€ (b : BExp), bequiv b (btrans b)" }, { "name": "Imp.fold_constants_aexp", "content": "def fold_constants_aexp (a : AExp) : AExp :=\n match a with\n | a_num _\n | a_id _\n => a\n | a_plus a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => a_num (n1 + n2)\n | (a1', a2') => a_plus a1' a2'\n | a_minus a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => a_num (n1 - n2)\n | (a1', a2') => a_minus a1' a2'\n | a_mult a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => a_num (n1 * n2)\n | (a1', a2') => a_mult a1' a2'\n\nexample : fold_constants_aexp <{(1 + 2) * x}> = <{3 * x}> := by admit /- proof elided -/" }, { "name": "Imp.fold_constants_bexp", "content": "def fold_constants_bexp (b : BExp) : BExp :=\n match b with\n | b_true\n | b_false\n => b\n | b_eq a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => if n1 == n2 then b_true else b_false\n | (a1', a2') => b_eq a1' a2'\n | b_neq a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => if n1 != n2 then b_true else b_false\n | (a1', a2') => b_neq a1' a2'\n | b_le a1 a2 =>\n match (fold_constants_aexp a1, fold_constants_aexp a2) with\n | (a_num n1, a_num n2) => if n1 <= n2 then b_true else b_false\n | (a1', a2') => b_le a1' a2'\n | b_not b1 =>\n match fold_constants_bexp b1 with\n | b_true => b_false\n | b_false => b_true\n | b1' => b_not b1'\n | b_and b1 b2 =>\n match (fold_constants_bexp b1, fold_constants_bexp b2) with\n | (b_true, b_true) => b_true\n | (b_true, b_false) => b_false\n | (b_false, b_true) => b_false\n | (b_false, b_false) => b_false\n | (b1', b2') => b_and b1' b2'\n | b_or b1 b2 =>\n match (fold_constants_bexp b1, fold_constants_bexp b2) with\n | (b_true, b_true) => b_true\n | (b_true, b_false) => b_true\n | (b_false, b_true) => b_true\n | (b_false, b_false) => b_false\n | (b1', b2') => b_or b1' b2'\n\nexample : fold_constants_bexp <{true && !(false && true)}> = <{true}> := by admit /- proof elided -/" } ]
[ { "name": "Imp.fold_constants_aexp_sound", "content": "theorem fold_constants_aexp_sound : atrans_sound fold_constants_aexp" } ]
import Frap.Equiv import Frap.Exercises.Equiv namespace Imp open AExp open BExp open Com open CEval def atrans_sound (atrans : AExp β†’ AExp) := βˆ€ (a : AExp), aequiv a (atrans a) def btrans_sound (btrans : BExp β†’ BExp) := βˆ€ (b : BExp), bequiv b (btrans b) def fold_constants_aexp (a : AExp) : AExp := match a with | a_num _ | a_id _ => a | a_plus a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => a_num (n1 + n2) | (a1', a2') => a_plus a1' a2' | a_minus a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => a_num (n1 - n2) | (a1', a2') => a_minus a1' a2' | a_mult a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => a_num (n1 * n2) | (a1', a2') => a_mult a1' a2' example : fold_constants_aexp <{(1 + 2) * x}> = <{3 * x}> := by admit /- proof elided -/ def fold_constants_bexp (b : BExp) : BExp := match b with | b_true | b_false => b | b_eq a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => if n1 == n2 then b_true else b_false | (a1', a2') => b_eq a1' a2' | b_neq a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => if n1 != n2 then b_true else b_false | (a1', a2') => b_neq a1' a2' | b_le a1 a2 => match (fold_constants_aexp a1, fold_constants_aexp a2) with | (a_num n1, a_num n2) => if n1 <= n2 then b_true else b_false | (a1', a2') => b_le a1' a2' | b_not b1 => match fold_constants_bexp b1 with | b_true => b_false | b_false => b_true | b1' => b_not b1' | b_and b1 b2 => match (fold_constants_bexp b1, fold_constants_bexp b2) with | (b_true, b_true) => b_true | (b_true, b_false) => b_false | (b_false, b_true) => b_false | (b_false, b_false) => b_false | (b1', b2') => b_and b1' b2' | b_or b1 b2 => match (fold_constants_bexp b1, fold_constants_bexp b2) with | (b_true, b_true) => b_true | (b_true, b_false) => b_true | (b_false, b_true) => b_true | (b_false, b_false) => b_false | (b1', b2') => b_or b1' b2' example : fold_constants_bexp <{true && !(false && true)}> = <{true}> := by admit /- proof elided -/
theorem fold_constants_bexp_sound : btrans_sound fold_constants_bexp :=
:= by intro b st; induction b with simp [fold_constants_bexp] | b_eq a1 a2 => rw [fold_constants_aexp_sound a1, fold_constants_aexp_sound a2] split . rename_i hm simp at hm obtain ⟨⟩ := hm split <;> simp [*] . rename_i hm simp at hm obtain ⟨⟩ := hm simp [*] | b_neq a1 a2 => rw [fold_constants_aexp_sound a1, fold_constants_aexp_sound a2] split . rename_i hm simp at hm obtain ⟨⟩ := hm split <;> simp [*] . rename_i hm simp at hm obtain ⟨⟩ := hm simp [*] | b_le a1 a2 => rw [fold_constants_aexp_sound a1, fold_constants_aexp_sound a2] split . rename_i hm simp at hm obtain ⟨⟩ := hm split <;> simp [*] . rename_i hm simp at hm obtain ⟨⟩ := hm simp [*] | b_not => split <;> simp [*] | b_and => simp [*] split <;> ( rename_i hm simp at hm obtain ⟨⟩ := hm simp [*] ) | b_or => simp [*] split <;> ( rename_i hm simp at hm obtain ⟨⟩ := hm simp [*] )
5
21
true
Semantics
275
step_normalizing
theorem step_normalizing : normalizing Step
lean-formal-reasoning-program
Frap/SmallStep.lean
[]
[ { "name": "Nat", "module": "Init.Prelude" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Tm", "content": "inductive Tm : Type :=\n | c : Nat β†’ Tm \n | p : Tm β†’ Tm β†’ Tm" }, { "name": "SimpleArith1.Step", "content": "inductive Step : Tm β†’ Tm β†’ Prop :=\n | st_plusConstConst n₁ nβ‚‚ : Step (p (c n₁) (c nβ‚‚)) (c (n₁ + nβ‚‚))\n | st_plus1 t₁ t₁' tβ‚‚ : Step t₁ t₁' β†’ Step (p t₁ tβ‚‚) (p t₁' tβ‚‚)\n | st_plus2 n₁ tβ‚‚ tβ‚‚' : Step tβ‚‚ tβ‚‚' β†’ Step (p (c n₁) tβ‚‚) (p (c n₁) tβ‚‚')" }, { "name": "relation", "content": "def relation (X : Type) := X β†’ X β†’ Prop" }, { "name": "Value", "content": "inductive Value : Tm β†’ Prop :=\n | v_const n : Value (c n)" }, { "name": "Step", "content": "inductive Step : Tm β†’ Tm β†’ Prop :=\n | st_plusConstConst n₁ nβ‚‚ : Step (p (c n₁) (c nβ‚‚)) (c (n₁ + nβ‚‚))\n | st_plus1 t₁ t₁' tβ‚‚ : Step t₁ t₁' β†’ Step (p t₁ tβ‚‚) (p t₁' tβ‚‚)\n | st_plus2 v₁ tβ‚‚ tβ‚‚' : Value v₁ β†’ Step tβ‚‚ tβ‚‚' β†’ Step (p v₁ tβ‚‚) (p v₁ tβ‚‚')" }, { "name": "normal_form", "content": "def normal_form {X : Type} (R : relation X) (t : X) : Prop := Β¬βˆƒt', R t t'" }, { "name": "Multi", "content": "inductive Multi {X : Type} (R : relation X) : relation X :=\n | multi_refl x : Multi R x x\n | multi_step x y z : R x y β†’ Multi R y z β†’ Multi R x z" }, { "name": "normalizing", "content": "def normalizing {X : Type} (R : relation X) :=\n βˆ€t, βˆƒt', (Multi R) t t' ∧ normal_form R t'" } ]
[ { "name": "strong_progress", "content": "theorem strong_progress t : Value t ∨ βˆƒt', Step t t'" }, { "name": "value_is_nf", "content": "theorem value_is_nf v : Value v β†’ normal_form Step v" }, { "name": "nf_is_value", "content": "theorem nf_is_value t : normal_form Step t β†’ Value t" }, { "name": "nf_same_as_value", "content": "theorem nf_same_as_value t : normal_form Step t ↔ Value t" }, { "name": "multi_R", "content": "theorem multi_R (X : Type) (R : relation X) x y : R x y β†’ Multi R x y" }, { "name": "multi_trans", "content": "theorem multi_trans (X : Type) (R : relation X) x y z\n : Multi R x y β†’ Multi R y z β†’ Multi R x z" }, { "name": "multistep_congr_1", "content": "theorem multistep_congr_1 t₁ t₁' tβ‚‚\n : (t₁ ~~>* t₁') β†’ (p t₁ tβ‚‚ ~~>* p t₁' tβ‚‚)" }, { "name": "multistep_congr_2", "content": "theorem multistep_congr_2 v₁ tβ‚‚ tβ‚‚'\n : (tβ‚‚ ~~>* tβ‚‚') β†’ (p v₁ tβ‚‚ ~~>* p v₁ tβ‚‚')" } ]
inductive Tm : Type := | c : Nat β†’ Tm | p : Tm β†’ Tm β†’ Tm open Tm open Eval namespace SimpleArith1 inductive Step : Tm β†’ Tm β†’ Prop := | st_plusConstConst n₁ nβ‚‚ : Step (p (c n₁) (c nβ‚‚)) (c (n₁ + nβ‚‚)) | st_plus1 t₁ t₁' tβ‚‚ : Step t₁ t₁' β†’ Step (p t₁ tβ‚‚) (p t₁' tβ‚‚) | st_plus2 n₁ tβ‚‚ tβ‚‚' : Step tβ‚‚ tβ‚‚' β†’ Step (p (c n₁) tβ‚‚) (p (c n₁) tβ‚‚') open Step end SimpleArith1 def relation (X : Type) := X β†’ X β†’ Prop namespace SimpleArith2 open SimpleArith1 end SimpleArith2 inductive Value : Tm β†’ Prop := | v_const n : Value (c n) open Value inductive Step : Tm β†’ Tm β†’ Prop := | st_plusConstConst n₁ nβ‚‚ : Step (p (c n₁) (c nβ‚‚)) (c (n₁ + nβ‚‚)) | st_plus1 t₁ t₁' tβ‚‚ : Step t₁ t₁' β†’ Step (p t₁ tβ‚‚) (p t₁' tβ‚‚) | st_plus2 v₁ tβ‚‚ tβ‚‚' : Value v₁ β†’ Step tβ‚‚ tβ‚‚' β†’ Step (p v₁ tβ‚‚) (p v₁ tβ‚‚') open Step def normal_form {X : Type} (R : relation X) (t : X) : Prop := Β¬βˆƒt', R t t' inductive Multi {X : Type} (R : relation X) : relation X := | multi_refl x : Multi R x x | multi_step x y z : R x y β†’ Multi R y z β†’ Multi R x z open Multi def normalizing {X : Type} (R : relation X) := βˆ€t, βˆƒt', (Multi R) t t' ∧ normal_form R t'
theorem step_normalizing : normalizing Step :=
:= by unfold normalizing intro t induction t with | c n => exists c n constructor . apply multi_refl . rw [nf_same_as_value]; apply v_const | p t₁ tβ‚‚ ih₁ ihβ‚‚ => obtain ⟨t₁', ⟨hs₁, hnβ‚βŸ©βŸ© := ih₁ obtain ⟨tβ‚‚', ⟨hsβ‚‚, hnβ‚‚βŸ©βŸ© := ihβ‚‚ rw [nf_same_as_value] at hn₁ rw [nf_same_as_value] at hnβ‚‚ cases hn₁; cases hnβ‚‚ rename_i n₁ nβ‚‚ exists c (n₁ + nβ‚‚) constructor . apply multi_trans . apply multistep_congr_1 apply hs₁ . apply multi_trans . apply multistep_congr_2 apply hsβ‚‚ . apply multi_R apply st_plusConstConst . rw [nf_same_as_value]; apply v_const
3
17
true
Semantics
276
Imp.optimize_0plus_com_sound
theorem optimize_0plus_com_sound : ctrans_sound optimize_0plus_com
lean-formal-reasoning-program
Frap/Exercises/Trans.lean
[ "import Frap.Trans" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "syntax \"<{\" imp \"}>\" : term", "content": "syntax \"<{\" imp \"}>\" : term\n\nsyntax:21 \"while\" imp:20 \"do\" imp:20 \"end\" : imp\n\nsyntax \"<[\" term \"]>\" : imp\n\nsyntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : imp\n\nsyntax \"false\" : imp\n\nsyntax \"false\" : term\n\nsyntax \"true\" : imp\n\nsyntax \"true\" : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|true) => `(Bool.true)\n | `(term|false) => `(Bool.false)\n | `(term|<{$x}>) => `(imp|$x)\n | `(imp|$n:num) => `(a_num $n)\n | `(imp|$s:str) => `(a_id $s)\n | `(imp|$x + $y) => `(a_plus <{$x}> <{$y}>)\n | `(imp|$x - $y) => `(a_minus <{$x}> <{$y}>)\n | `(imp|$x * $y) => `(a_mult <{$x}> <{$y}>)\n | `(imp|true) => `(b_true)\n | `(imp|false) => `(b_false)\n | `(imp|$x = $y) => `(b_eq <{$x}> <{$y}>)\n | `(imp|$x != $y) => `(b_neq <{$x}> <{$y}>)\n | `(imp|$x <= $y) => `(b_le <{$x}> <{$y}>)\n | `(imp|!$x) => `(b_not <{$x}>)\n | `(imp|$x && $y) => `(b_and <{$x}> <{$y}>)\n | `(imp|$x || $y) => `(b_or <{$x}> <{$y}>)\n | `(imp|($x)) => `(<{$x}>)\n | `(imp|$x:ident) => `(a_id $(Lean.quote (toString x.getId)))\n | `(imp|<[$t:term]>) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(imp|skip) => `(c_skip)\n | `(imp|$x:str := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$x:ident := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$c1 ; $c2) => `(c_seq <{$c1}> <{$c2}>)\n | `(imp|if $b then $c1 else $c2 end) => `(c_if <{$b}> <{$c1}> <{$c2}>)\n | `(imp|while $b do $c end) => `(c_while <{$b}> <{$c}>)" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_id : String β†’ AExp \n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "BExp", "content": "inductive BExp where\n | b_true : BExp\n | b_false : BExp\n | b_eq : AExp β†’ AExp β†’ BExp\n | b_neq : AExp β†’ AExp β†’ BExp\n | b_le : AExp β†’ AExp β†’ BExp\n | b_not : BExp β†’ BExp\n | b_and : BExp β†’ BExp β†’ BExp\n | b_or : BExp β†’ BExp β†’ BExp" }, { "name": "Com", "content": "inductive Com :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com" }, { "name": "Com", "content": "inductive Com : Type :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com\n | c_par : Com β†’ Com β†’ Com " }, { "name": "ctrans_sound", "content": "def ctrans_sound (ctrans : Com β†’ Com) :=\n βˆ€ (c : Com), cequiv c (ctrans c)" }, { "name": "cequiv", "content": "def cequiv (c₁ cβ‚‚ : Com) : Prop :=\n βˆ€ st st' : State, (st =[<[c₁]>]=> st') ↔ (st =[<[cβ‚‚]>]=> st')" }, { "name": "State", "content": "abbrev State := String β†’ Nat" }, { "name": "btrans_sound", "content": "def btrans_sound (btrans : BExp β†’ BExp) :=\n βˆ€ (b : BExp), bequiv b (btrans b)" }, { "name": "bequiv", "content": "def bequiv (b₁ bβ‚‚ : BExp) : Prop :=\n βˆ€ (st : State), beval st b₁ = beval st bβ‚‚" }, { "name": "beval", "content": "def beval (st : State) (b : BExp) : Bool :=\n match b with\n | b_true => true\n | b_false => false\n | b_eq a₁ aβ‚‚ => (aeval st a₁) == (aeval st aβ‚‚)\n | b_neq a₁ aβ‚‚ => (aeval st a₁) != (aeval st aβ‚‚)\n | b_le a₁ aβ‚‚ => (aeval st a₁) <= (aeval st aβ‚‚)\n | b_not b₁ => not (beval st b₁)\n | b_and b₁ bβ‚‚ => and (beval st b₁) (beval st bβ‚‚)\n | b_or b₁ bβ‚‚ => or (beval st b₁) (beval st bβ‚‚)\n\nexample : aeval (update empty x 5)\n <{3 + x * 2}>\n \n = 13 := by admit /- proof elided -/" }, { "name": "empty", "content": "def empty : State := fun _ => 0" }, { "name": "y", "content": "abbrev y := \"y\"" }, { "name": "x", "content": "abbrev x := \"x\"" }, { "name": "z", "content": "abbrev z := \"z\"" }, { "name": "aeval", "content": "def aeval (st : State) (a : AExp) : Nat :=\n match a with\n | a_num n => n\n | a_id x => st x\n | a_plus a₁ aβ‚‚ => (aeval st a₁) + (aeval st aβ‚‚)\n | a_minus a₁ aβ‚‚ => (aeval st a₁) - (aeval st aβ‚‚)\n | a_mult a₁ aβ‚‚ => (aeval st a₁) * (aeval st aβ‚‚)" }, { "name": "update", "content": "def update (st : State) (k : String) (v : Nat) : State :=\n fun x => if x == k then v else st x" }, { "name": "atrans_sound", "content": "def atrans_sound (atrans : AExp β†’ AExp) :=\n βˆ€ (a : AExp), aequiv a (atrans a)" }, { "name": "aequiv", "content": "def aequiv (a₁ aβ‚‚ : AExp) : Prop :=\n βˆ€ (st : State), aeval st a₁ = aeval st aβ‚‚" }, { "name": "CEval", "content": "inductive CEval : Com β†’ State β†’ State β†’ Prop :=\n | e_skip : βˆ€ st,\n CEval c_skip st st\n | e_asgn : βˆ€ a n x st,\n aeval st a = n\n β†’ CEval (c_asgn x a) st (update st x n)\n | e_seq : βˆ€ c₁ cβ‚‚ st st' st'',\n CEval c₁ st st' β†’ CEval cβ‚‚ st' st''\n β†’ CEval (c_seq c₁ cβ‚‚) st st''\n | e_ifTrue : βˆ€ b c₁ cβ‚‚ st st',\n beval st b = true β†’ CEval c₁ st st'\n β†’ CEval (c_if b c₁ cβ‚‚) st st'\n | e_ifFalse : βˆ€ b c₁ cβ‚‚ st st',\n beval st b = false β†’ CEval cβ‚‚ st st'\n β†’ CEval (c_if b c₁ cβ‚‚) st st'\n | e_whileFalse : βˆ€ b c st,\n beval st b = false\n β†’ CEval (c_while b c) st st\n | e_whileTrue : βˆ€ b c st st' st'',\n beval st b = true\n β†’ CEval c st st'\n β†’ CEval (c_while b c) st' st''\n β†’ CEval (c_while b c) st st''" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "c_while_congruence", "content": "theorem c_while_congruence b b' c c'\n : bequiv b b' β†’ cequiv c c'\n β†’ cequiv <{while <[b]> do <[c]> end}> <{while <[b']> do <[c']> end}>" }, { "name": "sym_bequiv", "content": "theorem sym_bequiv b₁ bβ‚‚ : bequiv b₁ bβ‚‚ β†’ bequiv bβ‚‚ b₁" }, { "name": "sym_cequiv", "content": "theorem sym_cequiv c₁ cβ‚‚ : cequiv c₁ cβ‚‚ β†’ cequiv cβ‚‚ c₁" }, { "name": "c_if_congruence", "content": "theorem c_if_congruence b b' c₁ c₁' cβ‚‚ cβ‚‚'\n : bequiv b b' β†’ cequiv c₁ c₁' β†’ cequiv cβ‚‚ cβ‚‚'\n β†’ cequiv (c_if b c₁ cβ‚‚) (c_if b' c₁' cβ‚‚')" }, { "name": "c_asgn_congruence", "content": "theorem c_asgn_congruence x a a'\n : aequiv a a' β†’ cequiv <{x := <[a]>}> <{x := <[a']>}>" }, { "name": "c_seq_congruence", "content": "theorem c_seq_congruence c₁ c₁' cβ‚‚ cβ‚‚'\n : cequiv c₁ c₁' β†’ cequiv cβ‚‚ cβ‚‚' β†’ cequiv (c_seq c₁ cβ‚‚) (c_seq c₁' cβ‚‚')" }, { "name": "refl_cequiv", "content": "theorem refl_cequiv c : cequiv c c" } ]
[ { "name": "Imp.optimize_0plus_aexp", "content": "def optimize_0plus_aexp (a : AExp) : AExp :=\n match a with\n | a_num _ => a\n | a_id _ => a\n | a_plus (a_num 0) aβ‚‚ => optimize_0plus_aexp aβ‚‚\n | a_plus a₁ aβ‚‚ => a_plus (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚)\n | a_minus a₁ aβ‚‚ => a_minus (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚)\n | a_mult a₁ aβ‚‚ => a_mult (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚)" }, { "name": "Imp.optimize_0plus_bexp", "content": "def optimize_0plus_bexp (b : BExp) : BExp :=\n match b with\n | b_true => b_true\n | b_false => b_false\n | b_eq a₁ aβ‚‚ => b_eq (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚)\n | b_neq a₁ aβ‚‚ => b_neq (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚)\n | b_le a₁ aβ‚‚ => b_le (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚)\n | b_not b₁ => b_not (optimize_0plus_bexp b₁)\n | b_and b₁ bβ‚‚ => b_and (optimize_0plus_bexp b₁) (optimize_0plus_bexp bβ‚‚)\n | b_or b₁ bβ‚‚ => b_or (optimize_0plus_bexp b₁) (optimize_0plus_bexp bβ‚‚)" }, { "name": "Imp.optimize_0plus_com", "content": "def optimize_0plus_com (c : Com) : Com :=\n match c with\n | c_skip => c_skip\n | c_asgn x a => c_asgn x (optimize_0plus_aexp a)\n | c_seq c₁ cβ‚‚ => c_seq (optimize_0plus_com c₁) (optimize_0plus_com cβ‚‚)\n | c_if b c₁ cβ‚‚ => c_if (optimize_0plus_bexp b) (optimize_0plus_com c₁) (optimize_0plus_com cβ‚‚)\n | c_while b c => c_while (optimize_0plus_bexp b) (optimize_0plus_com c)\n\n \n\nexample :\n optimize_0plus_com <{ while x != 0 do x := 0 + x - 1 end }>\n = <{ while x != 0 do x := x - 1 end }> := by admit /- proof elided -/" } ]
[ { "name": "Imp.optimize_0plus_aexp_sound", "content": "theorem optimize_0plus_aexp_sound : atrans_sound optimize_0plus_aexp" }, { "name": "Imp.optimize_0plus_bexp_sound", "content": "theorem optimize_0plus_bexp_sound : btrans_sound optimize_0plus_bexp" } ]
import Frap.Trans namespace Hidden.AExp open AExp end Hidden.AExp namespace Imp open AExp open BExp open Com open CEval def optimize_0plus_aexp (a : AExp) : AExp := match a with | a_num _ => a | a_id _ => a | a_plus (a_num 0) aβ‚‚ => optimize_0plus_aexp aβ‚‚ | a_plus a₁ aβ‚‚ => a_plus (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚) | a_minus a₁ aβ‚‚ => a_minus (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚) | a_mult a₁ aβ‚‚ => a_mult (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚) def optimize_0plus_bexp (b : BExp) : BExp := match b with | b_true => b_true | b_false => b_false | b_eq a₁ aβ‚‚ => b_eq (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚) | b_neq a₁ aβ‚‚ => b_neq (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚) | b_le a₁ aβ‚‚ => b_le (optimize_0plus_aexp a₁) (optimize_0plus_aexp aβ‚‚) | b_not b₁ => b_not (optimize_0plus_bexp b₁) | b_and b₁ bβ‚‚ => b_and (optimize_0plus_bexp b₁) (optimize_0plus_bexp bβ‚‚) | b_or b₁ bβ‚‚ => b_or (optimize_0plus_bexp b₁) (optimize_0plus_bexp bβ‚‚) def optimize_0plus_com (c : Com) : Com := match c with | c_skip => c_skip | c_asgn x a => c_asgn x (optimize_0plus_aexp a) | c_seq c₁ cβ‚‚ => c_seq (optimize_0plus_com c₁) (optimize_0plus_com cβ‚‚) | c_if b c₁ cβ‚‚ => c_if (optimize_0plus_bexp b) (optimize_0plus_com c₁) (optimize_0plus_com cβ‚‚) | c_while b c => c_while (optimize_0plus_bexp b) (optimize_0plus_com c) example : optimize_0plus_com <{ while x != 0 do x := 0 + x - 1 end }> = <{ while x != 0 do x := x - 1 end }> := by admit /- proof elided -/
theorem optimize_0plus_com_sound : ctrans_sound optimize_0plus_com :=
:= by intros c induction c with simp [*] at * | c_skip => apply refl_cequiv | c_asgn => apply c_asgn_congruence; apply optimize_0plus_aexp_sound | c_seq => apply c_seq_congruence . assumption . assumption | c_if => apply c_if_congruence . apply optimize_0plus_bexp_sound . assumption . assumption | c_while => apply c_while_congruence . apply optimize_0plus_bexp_sound . assumption
6
35
false
Semantics
277
Tree.balance_BST
theorem balance_BST {Ξ± : Type u} c (l : Tree Ξ±) k vk (r : Tree Ξ±) : ForallTree (fun x _ => x < k) l -> ForallTree (fun x _ => x > k) r -> BST l -> BST r -> BST (balance c l k vk r)
lean-formal-reasoning-program
Frap/RedBlack.lean
[]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Color", "content": "inductive Color where\n | red\n | black" }, { "name": "Tree", "content": "inductive Tree (Ξ± : Type u) where\n | empty : Tree Ξ±\n | tree (c: Color) (l : Tree Ξ±) (k : Nat) (v : Ξ±) (r : Tree Ξ±) : Tree Ξ±" }, { "name": "Tree.ex_tree", "content": "def ex_tree : Tree String :=\n tree black (tree red empty 2 \"two\" empty) 4 \"four\" (tree red empty 5 \"five\" empty)" }, { "name": "Tree.balance", "content": "def balance {Ξ± : Type u} (c : Color) (l : Tree Ξ±) (k : Nat) (vk : Ξ±) (r : Tree Ξ±) : Tree Ξ± :=\n match c with\n | red => tree red l k vk r\n | black =>\n match (l, k, vk, r) with\n | (tree red (tree red a x vx b) y vy c, z, vz, d)\n | (tree red a x vx (tree red b y vy c), z, vz, d)\n | (a, x, vx, tree red (tree red b y vy c) z vz d)\n | (a, x, vx, tree red b y vy (tree red c z vz d))\n => tree red (tree black a x vx b) y vy (tree black c z vz d)\n | _ => tree black l k vk r" }, { "name": "Tree.ForallTree", "content": "inductive ForallTree {Ξ± : Type u} (p : Nat β†’ Ξ± β†’ Prop) : Tree Ξ± β†’ Prop where\n | empty : ForallTree p empty\n | tree : βˆ€ c l k v r,\n p k v β†’ ForallTree p l β†’ ForallTree p r\n β†’ ForallTree p (tree c l k v r)" }, { "name": "Tree.BST", "content": "inductive BST {Ξ± : Type u} : Tree Ξ± β†’ Prop where\n | empty : BST empty\n | tree : βˆ€ c l k v r,\n ForallTree (fun x _ => x < k) l\n β†’ ForallTree (fun x _ => x > k) r\n β†’ BST l\n β†’ BST r\n β†’ BST (tree c l k v r)\n\n \n\nexample : BST ex_tree := by admit /- proof elided -/" } ]
[ { "name": "Tree.forallTree_imp", "content": "theorem forallTree_imp {Ξ± : Type u} (P Q : Nat β†’ Ξ± β†’ Prop) t\n : ForallTree P t β†’ (βˆ€ k v, P k v β†’ Q k v) β†’ ForallTree Q t" }, { "name": "Tree.forallTree_lt", "content": "theorem forallTree_lt {Ξ± : Type u} (t : Tree Ξ±) k k'\n : ForallTree (fun x _ => x < k) t β†’ k < k'\n β†’ ForallTree (fun x _ => x < k') t" }, { "name": "Tree.forallTree_gt", "content": "theorem forallTree_gt {Ξ± : Type u} (t : Tree Ξ±) k k'\n : ForallTree (fun x _ => x > k) t β†’ k > k'\n β†’ ForallTree (fun x _ => x > k') t" } ]
inductive Color where | red | black inductive Tree (Ξ± : Type u) where | empty : Tree Ξ± | tree (c: Color) (l : Tree Ξ±) (k : Nat) (v : Ξ±) (r : Tree Ξ±) : Tree Ξ± namespace Tree open Color def ex_tree : Tree String := tree black (tree red empty 2 "two" empty) 4 "four" (tree red empty 5 "five" empty) def balance {Ξ± : Type u} (c : Color) (l : Tree Ξ±) (k : Nat) (vk : Ξ±) (r : Tree Ξ±) : Tree Ξ± := match c with | red => tree red l k vk r | black => match (l, k, vk, r) with | (tree red (tree red a x vx b) y vy c, z, vz, d) | (tree red a x vx (tree red b y vy c), z, vz, d) | (a, x, vx, tree red (tree red b y vy c) z vz d) | (a, x, vx, tree red b y vy (tree red c z vz d)) => tree red (tree black a x vx b) y vy (tree black c z vz d) | _ => tree black l k vk r inductive ForallTree {Ξ± : Type u} (p : Nat β†’ Ξ± β†’ Prop) : Tree Ξ± β†’ Prop where | empty : ForallTree p empty | tree : βˆ€ c l k v r, p k v β†’ ForallTree p l β†’ ForallTree p r β†’ ForallTree p (tree c l k v r) inductive BST {Ξ± : Type u} : Tree Ξ± β†’ Prop where | empty : BST empty | tree : βˆ€ c l k v r, ForallTree (fun x _ => x < k) l β†’ ForallTree (fun x _ => x > k) r β†’ BST l β†’ BST r β†’ BST (tree c l k v r) example : BST ex_tree := by admit /- proof elided -/
theorem balance_BST {Ξ± : Type u} c (l : Tree Ξ±) k vk (r : Tree Ξ±) : ForallTree (fun x _ => x < k) l -> ForallTree (fun x _ => x > k) r -> BST l -> BST r -> BST (balance c l k vk r) :=
:= by intro hlk hkr hbl hbr; simp split . constructor <;> assumption . split . -- we are in the case where `x` is left child of `y` cases l <;> repeat simp [*] at * rcases hbl with ⟨⟩ | ⟨_, _, _, _, _, hxy, hyc, hbx, hbc⟩ rcases hlk with ⟨⟩ | ⟨_, _, _, _, _, hyz, hxz, hzc⟩ rcases hbx with ⟨⟩ | ⟨_, _, _, _, _, hax, hxb, hba, hbb⟩ rcases hxy with ⟨⟩ | ⟨_, _, _, _, _, hxy, hay, hby⟩ rcases hxz with ⟨⟩ | ⟨_, _, _, _, _, haz, hxz, hbz⟩ /- Here, we have destructed all the assumptions to the atomic level. The goal remains to show that the resulting tree is a BST. We apply the constructor tactic repeatedly. Most of the resulting subgoals are trivial by assumption. -/ (repeat' constructor) <;> try assumption /- The only interesting subgoal is to show that each node in the right subtree of the original root is greater than the left child of the original root. This should follow from assumptions, although not trivially. To facilitate reasoning at this point, we prove lemmas `forallTree_imp`, `forallTree_lt`, and `forallTree_gt` above. -/ apply forallTree_gt <;> assumption . -- we are in the case where `y` is right child of `x` cases l <;> repeat simp [*] at * rcases hbl with ⟨⟩ | ⟨_, _, _, _, _, hax, hxy, hba, hby⟩ rcases hlk with ⟨⟩ | ⟨_, _, _, _, _, hxz, haz, hyz⟩ rcases hby with ⟨⟩ | ⟨_, _, _, _, _, hby, hyc, hbb, hbc⟩ rcases hxy with ⟨⟩ | ⟨_, _, _, _, _, hxy, hxb, hxc⟩ rcases hyz with ⟨⟩ | ⟨_, _, _, _, _, hyz, hbz, hcz⟩ (repeat' constructor) <;> try assumption . apply forallTree_lt . exact hax . assumption . apply forallTree_gt <;> assumption . -- we are in the case where `y` is left child of `z` cases r <;> repeat simp [*] at * rcases hbr with ⟨⟩ | ⟨_, _, _, _, _, hyz, hzd, hby, hbd⟩ rcases hkr with ⟨⟩ | ⟨_, _, _, _, _, hxz, hxy, hxd⟩ rcases hby with ⟨⟩ | ⟨_, _, _, _, _, hby, hyc, hbb, hbc⟩ rcases hxy with ⟨⟩ | ⟨_, _, _, _, _, hxy, hxb, hxc⟩ rcases hyz with ⟨⟩ | ⟨_, _, _, _, _, hyz, hbz, hcz⟩ (repeat' constructor) <;> try assumption . apply forallTree_lt <;> assumption . apply forallTree_gt . exact hzd . assumption . -- we are in the case where `z` is right child of `y` cases r <;> repeat simp [*] at * rcases hbr with ⟨⟩ | ⟨_, _, _, _, _, hby, hyz, hbb, hbz⟩ rcases hkr with ⟨⟩ | ⟨_, _, _, _, _, hxy, hxb, hxz⟩ rcases hbz with ⟨⟩ | ⟨_, _, _, _, _, hcz, hzd, hbc, hbd⟩ rcases hxz with ⟨⟩ | ⟨_, _, _, _, _, hxz, hxc, hxd⟩ rcases hyz with ⟨⟩ | ⟨_, _, _, _, _, hyz, hyc, hyd⟩ (repeat' constructor) <;> try assumption apply forallTree_lt <;> assumption . constructor <;> assumption
2
11
true
Semantics
278
permutation_app_comm
theorem permutation_app_comm (l l' : List Ξ±) : Permutation (l ++ l') (l' ++ l)
lean-formal-reasoning-program
Frap/Sort.lean
[]
[ { "name": "List", "module": "Init.Prelude" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "append_assoc", "content": "theorem append_assoc (as bs cs : List Ξ±)\n : (as ++ bs) ++ cs = as ++ (bs ++ cs)" } ]
[ { "name": "Permutation", "content": "inductive Permutation {Ξ± : Type} : List Ξ± β†’ List Ξ± β†’ Prop :=\n | perm_nil : Permutation [] []\n | perm_skip x l l'\n : Permutation l l' β†’ Permutation (x::l) (x::l')\n | perm_swap x y l : Permutation (y::x::l) (x::y::l)\n | perm_trans l l' l''\n : Permutation l l' β†’ Permutation l' l''\n β†’ Permutation l l''" } ]
[ { "name": "permutation_refl", "content": "theorem permutation_refl (l : List Ξ±) : Permutation l l" }, { "name": "permutation_symm", "content": "theorem permutation_symm (l l' : List Ξ±)\n : Permutation l l' β†’ Permutation l' l" }, { "name": "permutation_app_tail", "content": "theorem permutation_app_tail (l l' tl : List Ξ±)\n : Permutation l l' β†’ Permutation (l++tl) (l'++tl)" }, { "name": "permutation_app_head", "content": "theorem permutation_app_head (l tl tl' : List Ξ±)\n : Permutation tl tl' β†’ Permutation (l++tl) (l++tl')" }, { "name": "permutation_cons_append", "content": "theorem permutation_cons_append (l : List Ξ±) x\n : Permutation (x :: l) (l ++ [x])" } ]
inductive Permutation {Ξ± : Type} : List Ξ± β†’ List Ξ± β†’ Prop := | perm_nil : Permutation [] [] | perm_skip x l l' : Permutation l l' β†’ Permutation (x::l) (x::l') | perm_swap x y l : Permutation (y::x::l) (x::y::l) | perm_trans l l' l'' : Permutation l l' β†’ Permutation l' l'' β†’ Permutation l l'' open Permutation
theorem permutation_app_comm (l l' : List Ξ±) : Permutation (l ++ l') (l' ++ l) :=
:= by induction l with simp | nil => apply permutation_refl | cons a al ih => -- a :: (al ++ l') -- al ++ l' ++ [a] -- l' ++ al ++ [a] -- l' ++ (al ++ [a]) -- l' ++ a :: al apply perm_trans . apply permutation_cons_append . apply perm_trans . apply permutation_app_tail; exact ih . rw [List.append_assoc] apply permutation_app_head apply permutation_symm apply permutation_cons_append
2
8
false
Semantics
279
Hidden.Nat.add_comm
theorem add_comm (m n : Nat) : m + n = n + m
lean-formal-reasoning-program
Frap/Inductive.lean
[]
[ { "name": "structure BitVec (w : Nat) where", "module": "" }, { "name": "/-- Construct a `BitVec w` from a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "ofFin ::", "module": "" }, { "name": "/-- Interpret a bitvector as a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "toFin : Fin (hPow 2 w)", "module": "" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Hidden.Nat", "content": "inductive Nat where\n | zero : Nat\n | succ : Nat β†’ Nat" } ]
[ { "name": "Hidden.Nat.add_zero", "content": "theorem add_zero (m : Nat) : m + zero = m" }, { "name": "Hidden.Nat.add_succ", "content": "theorem add_succ (m n : Nat) : m + succ n = succ (m + n)" }, { "name": "Hidden.Nat.zero_add", "content": "theorem zero_add (n : Nat) : zero + n = n" }, { "name": "Hidden.Nat.succ_add", "content": "theorem succ_add (m n : Nat) : succ (m + n) = succ m + n" } ]
section rewriting variable (Ξ± : Type) (a b c d : Ξ±) -- a, b, c, d are elements of some type /- ## Rewriting Recall our equality proof from last time. -/ example : a = b β†’ c = b β†’ c = d β†’ a = d := by intro hab hcb hcd apply Eq.trans . exact hab . apply Eq.trans . apply Eq.symm exact hcb . exact hcd /- Notice that in each subgoal, we are attempting to use a hypothesis by way of an equality property. For example, we invoke the transitive property on `a = d` so that we can use the assumption `a = b` and be left with `b = d` to prove. In effect, we are substituting `b` for `a` in the goal. This substitution operation can be seen as rewriting some term in the goal with another, via an equality in the hypothesis. This rewriting operation is so common that Lean provides a `rw` tactic to do so. It replaces equals for equals, which could be an equality (`=`) or equivalence (`↔`). Be default, it rewrites the left-hand side with the right-hand side. For right-to-left rewriting, a left arrow needs to be indicated before the hypothesis (`←`, typed with `\<-` shortcut) . -/ example : a = b β†’ c = b β†’ c = d β†’ a = d := by intro hab hcb hcd rw [hab] rw [← hcd] rw [hcb] end rewriting /- ## reflexivity tactic One of the most powerful tactics is the _reflexivity_ tactic, written `rfl` in Lean. It will attempt to conclude that both sides of an equality goal is indeed equal, up to some trivial computation, such as expansion of definitions and function applications. -/ example : 2 + 5 = 7 := by rfl example : Β¬ Even = 3 := by intro h sorry namespace Hidden inductive Nat where | zero : Nat | succ : Nat β†’ Nat namespace Nat end Nat end Hidden section opendemo open Nat end opendemo namespace Hidden namespace Nat end Nat end Hidden namespace Hidden namespace Nat
theorem add_comm (m n : Nat) : m + n = n + m :=
:= by induction n with | zero => rw [add_zero] rw [zero_add] | succ n' ih => rw [add_succ] rw [ih] rw [succ_add] /- Alternatively, if the supporting fact is only useful within a single theorem, we can embed the proof within, using the -/ example (m n : Nat) : m + n = n + m := by induction n with | zero => rw [add_zero] rw [zero_add] | succ n' ih => rw [add_succ] rw [ih] have h (m n : Nat) : succ (m + n) = succ m + n := by induction n with | zero => rw [add_zero] rw [add_zero] | succ n' ih => rw [add_succ] rw [add_succ] rw [ih] rw [h]
1
5
false
Semantics
280
Hidden.List.Palindrome.Palindrome_rev
theorem Palindrome_rev {Ξ± : Type} (l : List Ξ±) : Palindrome l β†’ l = reverse l
lean-formal-reasoning-program
Frap/Exercises/IndProp.lean
[]
[ { "name": "structure BitVec (w : Nat) where", "module": "" }, { "name": "/-- Construct a `BitVec w` from a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "ofFin ::", "module": "" }, { "name": "/-- Interpret a bitvector as a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "toFin : Fin (hPow 2 w)", "module": "" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Hidden.List", "content": "inductive List (Ξ± : Type u) where\n | nil : List Ξ±\n | cons : Ξ± β†’ List Ξ± β†’ List Ξ±" }, { "name": "Hidden.List.reverse", "content": "def reverse {Ξ± : Type u} (as : List Ξ±) : List Ξ± :=\n match as with\n | nil => nil\n | cons a as' => reverse as' ++ cons a nil" }, { "name": "Hidden.List.Palindrome", "content": "inductive Palindrome {Ξ± : Type} : List Ξ± β†’ Prop where\n | nil : Palindrome nil\n | single (x : Ξ±) : Palindrome (cons x nil)\n | sandwich (x : Ξ±) (xs : List Ξ±)\n : Palindrome xs β†’ Palindrome (cons x xs ++ cons x nil)" } ]
[ { "name": "Hidden.List.nil_append", "content": "theorem nil_append (as : List Ξ±) : nil ++ as = as" }, { "name": "Hidden.List.cons_append", "content": "theorem cons_append (a : Ξ±) (as bs : List Ξ±)\n : (cons a as) ++ bs = cons a (as ++ bs)" }, { "name": "Hidden.List.append_nil", "content": "theorem append_nil (as : List Ξ±) : as ++ nil = as" }, { "name": "Hidden.List.append_assoc", "content": "theorem append_assoc (as bs cs : List Ξ±)\n : (as ++ bs) ++ cs = as ++ (bs ++ cs)" }, { "name": "Hidden.List.reverse_append", "content": "theorem reverse_append {Ξ± : Type u} (as bs : List Ξ±)\n : reverse (as ++ bs) = reverse bs ++ reverse as" } ]
namespace Hidden inductive List (Ξ± : Type u) where | nil : List Ξ± | cons : Ξ± β†’ List Ξ± β†’ List Ξ± namespace List def reverse {Ξ± : Type u} (as : List Ξ±) : List Ξ± := match as with | nil => nil | cons a as' => reverse as' ++ cons a nil inductive Palindrome {Ξ± : Type} : List Ξ± β†’ Prop where | nil : Palindrome nil | single (x : Ξ±) : Palindrome (cons x nil) | sandwich (x : Ξ±) (xs : List Ξ±) : Palindrome xs β†’ Palindrome (cons x xs ++ cons x nil) namespace Palindrome
theorem Palindrome_rev {Ξ± : Type} (l : List Ξ±) : Palindrome l β†’ l = reverse l :=
:= by intro lPal induction lPal with | nil => rfl | single x => rfl | sandwich x xs xsPal xsRev => rw [reverse_append, reverse, reverse, nil_append, reverse, ←xsRev] rw [cons_append, ←append_assoc, cons_append, nil_append, cons_append]
2
8
false
Semantics
281
Imp.Hoare.hoare_while
theorem hoare_while P b c : {* fun st => P st ∧ beval st b *} c {* P *} β†’ {* P *} c_while b c {* fun st => P st ∧ Β¬(beval st b) *}
lean-formal-reasoning-program
Frap/Hoare.lean
[ "import Frap.Trans" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "syntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : im", "content": "syntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : imp\n\nsyntax \"false\" : imp\n\nsyntax \"false\" : term\n\nsyntax \"true\" : imp\n\nsyntax \"true\" : term\n\nsyntax \"<{\" imp \"}>\" : term\n\nsyntax:21 \"while\" imp:20 \"do\" imp:20 \"end\" : imp\n\nsyntax:30 \"{*\" term \"*}\" term \"{*\" term \"*}\" : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|true) => `(Bool.true)\n | `(term|false) => `(Bool.false)\n | `(term|<{$x}>) => `(imp|$x)\n | `(imp|$n:num) => `(a_num $n)\n | `(imp|$s:str) => `(a_id $s)\n | `(imp|$x + $y) => `(a_plus <{$x}> <{$y}>)\n | `(imp|$x - $y) => `(a_minus <{$x}> <{$y}>)\n | `(imp|$x * $y) => `(a_mult <{$x}> <{$y}>)\n | `(imp|true) => `(b_true)\n | `(imp|false) => `(b_false)\n | `(imp|$x = $y) => `(b_eq <{$x}> <{$y}>)\n | `(imp|$x != $y) => `(b_neq <{$x}> <{$y}>)\n | `(imp|$x <= $y) => `(b_le <{$x}> <{$y}>)\n | `(imp|!$x) => `(b_not <{$x}>)\n | `(imp|$x && $y) => `(b_and <{$x}> <{$y}>)\n | `(imp|$x || $y) => `(b_or <{$x}> <{$y}>)\n | `(imp|($x)) => `(<{$x}>)\n | `(imp|$x:ident) => `(a_id $(Lean.quote (toString x.getId)))\n | `(imp|<[$t:term]>) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(imp|skip) => `(c_skip)\n | `(imp|$x:str := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$x:ident := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$c1 ; $c2) => `(c_seq <{$c1}> <{$c2}>)\n | `(imp|if $b then $c1 else $c2 end) => `(c_if <{$b}> <{$c1}> <{$c2}>)\n | `(imp|while $b do $c end) => `(c_while <{$b}> <{$c}>)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$p <<->> $q) => `($p ->> $q ∧ $q ->> $p)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|{*$p*} $c {*$q*}) => `(valid_hoare_triple $p $c $q)" }, { "name": "x", "content": "abbrev x := \"x\"" }, { "name": "beval", "content": "def beval (st : State) (b : BExp) : Bool :=\n match b with\n | b_true => true\n | b_false => false\n | b_eq a₁ aβ‚‚ => (aeval st a₁) == (aeval st aβ‚‚)\n | b_neq a₁ aβ‚‚ => (aeval st a₁) != (aeval st aβ‚‚)\n | b_le a₁ aβ‚‚ => (aeval st a₁) <= (aeval st aβ‚‚)\n | b_not b₁ => not (beval st b₁)\n | b_and b₁ bβ‚‚ => and (beval st b₁) (beval st bβ‚‚)\n | b_or b₁ bβ‚‚ => or (beval st b₁) (beval st bβ‚‚)\n\nexample : aeval (update empty x 5)\n <{3 + x * 2}>\n \n = 13 := by admit /- proof elided -/" }, { "name": "empty", "content": "def empty : State := fun _ => 0" }, { "name": "State", "content": "abbrev State := String β†’ Nat" }, { "name": "y", "content": "abbrev y := \"y\"" }, { "name": "z", "content": "abbrev z := \"z\"" }, { "name": "aeval", "content": "def aeval (st : State) (a : AExp) : Nat :=\n match a with\n | a_num n => n\n | a_id x => st x\n | a_plus a₁ aβ‚‚ => (aeval st a₁) + (aeval st aβ‚‚)\n | a_minus a₁ aβ‚‚ => (aeval st a₁) - (aeval st aβ‚‚)\n | a_mult a₁ aβ‚‚ => (aeval st a₁) * (aeval st aβ‚‚)" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_id : String β†’ AExp \n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "update", "content": "def update (st : State) (k : String) (v : Nat) : State :=\n fun x => if x == k then v else st x" }, { "name": "BExp", "content": "inductive BExp where\n | b_true : BExp\n | b_false : BExp\n | b_eq : AExp β†’ AExp β†’ BExp\n | b_neq : AExp β†’ AExp β†’ BExp\n | b_le : AExp β†’ AExp β†’ BExp\n | b_not : BExp β†’ BExp\n | b_and : BExp β†’ BExp β†’ BExp\n | b_or : BExp β†’ BExp β†’ BExp" }, { "name": "Com", "content": "inductive Com : Type :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com\n | c_par : Com β†’ Com β†’ Com" }, { "name": "CEval", "content": "inductive CEval : Com β†’ State β†’ State β†’ Prop :=\n | e_skip : βˆ€ st,\n CEval c_skip st st\n | e_asgn : βˆ€ a n x st,\n aeval st a = n\n β†’ CEval (c_asgn x a) st (update st x n)\n | e_seq : βˆ€ c₁ cβ‚‚ st st' st'',\n CEval c₁ st st' β†’ CEval cβ‚‚ st' st''\n β†’ CEval (c_seq c₁ cβ‚‚) st st''\n | e_ifTrue : βˆ€ b c₁ cβ‚‚ st st',\n beval st b = true β†’ CEval c₁ st st'\n β†’ CEval (c_if b c₁ cβ‚‚) st st'\n | e_ifFalse : βˆ€ b c₁ cβ‚‚ st st',\n beval st b = false β†’ CEval cβ‚‚ st st'\n β†’ CEval (c_if b c₁ cβ‚‚) st st'\n | e_whileFalse : βˆ€ b c st,\n beval st b = false\n β†’ CEval (c_while b c) st st\n | e_whileTrue : βˆ€ b c st st' st'',\n beval st b = true\n β†’ CEval c st st'\n β†’ CEval (c_while b c) st' st''\n β†’ CEval (c_while b c) st st''\n\nsyntax:30 term \" =[ \" imp \" ]=> \" term : term\nmacro_rules\n | `(term|$st =[ $c ]=> $st') => `(CEval <{$c}> $st $st')" }, { "name": "Assertion", "content": "abbrev Assertion := State β†’ Prop" }, { "name": "assert_implies", "content": "def assert_implies (P Q : Assertion) : Prop :=\n βˆ€ st, P st β†’ Q st" }, { "name": "valid_hoare_triple", "content": "def valid_hoare_triple (P : Assertion) (c : Com) (Q : Assertion) : Prop :=\n βˆ€ st st', P st β†’ (st =[<[c]>]=> st') β†’ Q st'" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[]
import Frap.Trans namespace Imp open AExp open BExp open Com open CEval namespace Hoare infix:36 " ->> " => assert_implies
theorem hoare_while P b c : {* fun st => P st ∧ beval st b *} c {* P *} β†’ {* P *} c_while b c {* fun st => P st ∧ Β¬(beval st b) *} :=
:= by intro hHoare st st' hPre hEval -- we proceed by induction on `hEval` generalize hloop : c_while b c = cmd at * induction hEval with simp at * | e_whileFalse => constructor . exact hPre . simp [*] | e_whileTrue => simp [*] at * rename_i ih apply ih apply hHoare . constructor . apply hPre . assumption . assumption /- We call `P` a _loop invariant_ of `while b do c` if `{P ∧ b} c {P}` is a valid Hoare triple. This means that `P` will be true at the end of the loop body whenever the loop body executes. If `P` contradicts `b`, this holds trivially since the precondition is false. For instance, `X = 0` is a loop invariant of `while X = 2 do X := 1 end` since the program will never enter the loop. The program `while Y > 10 do Y := Y - 1; Z := Z + 1 end` admits an interesting loop invariant: `X = Y + Z` Note that this doesn't contradict the loop guard but neither is it a command invariant of `Y := Y - 1; Z := Z + 1` since, if `X = 5`, `Y = 0` and `Z = 5`, running the command will set `Y + Z` to 6, because `Y` remains 0. The loop guard `Y > 10` guarantees that this will not be the case. We will see many such loop invariants in the following lecture. -/ example : -- { x ≀ 3 } {* fun st => st x ≀ 3 *} <{ while x <= 2 do x := x + 1
4
15
true
Semantics
282
Tree.bst_insert_of_bst
theorem bst_insert_of_bst {Ξ± : Type u} (k : Nat) (v : Ξ±) (t : Tree Ξ±) : BST t β†’ BST (insert k v t)
lean-formal-reasoning-program
Frap/ADT.lean
[]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "Nat.le_antisymm", "module": "Init.Prelude" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Tree", "content": "inductive Tree (Ξ± : Type u) where\n | empty : Tree Ξ±\n | tree (l : Tree Ξ±) (k : Nat) (v : Ξ±) (r : Tree Ξ±) : Tree Ξ±" }, { "name": "Tree.ex_tree", "content": "def ex_tree : Tree String :=\n tree (tree empty 2 \"two\" empty) 4 \"four\" (tree empty 5 \"five\" empty)" }, { "name": "Tree.insert", "content": "def insert {Ξ± : Type u} (x : Nat) (v : Ξ±) (t : Tree Ξ±) : Tree Ξ± :=\n match t with\n | empty => tree empty x v empty\n | tree l k v' r =>\n if x < k then tree (insert x v l) k v' r\n else if x > k then tree l k v' (insert x v r)\n else tree l x v r" }, { "name": "Tree.ForallTree", "content": "inductive ForallTree {Ξ± : Type u} (p : Nat β†’ Ξ± β†’ Prop) : Tree Ξ± β†’ Prop where\n | empty : ForallTree p empty\n | tree : βˆ€ l k v r,\n p k v β†’ ForallTree p l β†’ ForallTree p r\n β†’ ForallTree p (tree l k v r)" }, { "name": "Tree.BST", "content": "inductive BST {Ξ± : Type u} : Tree Ξ± β†’ Prop where\n | empty : BST empty\n | tree : βˆ€ l k v r,\n ForallTree (fun x _ => x < k) l\n β†’ ForallTree (fun x _ => x > k) r\n β†’ BST l\n β†’ BST r\n β†’ BST (tree l k v r)\n\nexample : BST ex_tree := by admit /- proof elided -/" } ]
[ { "name": "Tree.forall_insert_of_forall", "content": "theorem forall_insert_of_forall {Ξ± : Type u} (P : Nat β†’ Ξ± β†’ Prop) (t : Tree Ξ±)\n : ForallTree P t β†’ βˆ€ k v, P k v β†’ ForallTree P (insert k v t)" } ]
inductive Tree (Ξ± : Type u) where | empty : Tree Ξ± | tree (l : Tree Ξ±) (k : Nat) (v : Ξ±) (r : Tree Ξ±) : Tree Ξ± namespace Tree def ex_tree : Tree String := tree (tree empty 2 "two" empty) 4 "four" (tree empty 5 "five" empty) def insert {Ξ± : Type u} (x : Nat) (v : Ξ±) (t : Tree Ξ±) : Tree Ξ± := match t with | empty => tree empty x v empty | tree l k v' r => if x < k then tree (insert x v l) k v' r else if x > k then tree l k v' (insert x v r) else tree l x v r inductive ForallTree {Ξ± : Type u} (p : Nat β†’ Ξ± β†’ Prop) : Tree Ξ± β†’ Prop where | empty : ForallTree p empty | tree : βˆ€ l k v r, p k v β†’ ForallTree p l β†’ ForallTree p r β†’ ForallTree p (tree l k v r) inductive BST {Ξ± : Type u} : Tree Ξ± β†’ Prop where | empty : BST empty | tree : βˆ€ l k v r, ForallTree (fun x _ => x < k) l β†’ ForallTree (fun x _ => x > k) r β†’ BST l β†’ BST r β†’ BST (tree l k v r) example : BST ex_tree := by admit /- proof elided -/
theorem bst_insert_of_bst {Ξ± : Type u} (k : Nat) (v : Ξ±) (t : Tree Ξ±) : BST t β†’ BST (insert k v t) :=
:= by intro hbst induction hbst with | empty => constructor <;> constructor | tree l k' v' r hlt hgt hbstl hbstr => unfold insert split . constructor . apply forall_insert_of_forall . assumption . assumption . assumption . assumption . assumption . split . constructor . assumption . apply forall_insert_of_forall . assumption . assumption . assumption . assumption . have heq : k = k' := by simp [*] at * apply Nat.le_antisymm <;> assumption constructor . rw [heq]; assumption . rw [heq]; assumption . assumption . assumption
4
11
false
Semantics
283
Hidden.List.Palindrome.Palindrome_app_rev
theorem Palindrome_app_rev {Ξ± : Type} (l : List Ξ±) : Palindrome (l ++ reverse l)
lean-formal-reasoning-program
Frap/Exercises/IndProp.lean
[]
[ { "name": "structure BitVec (w : Nat) where", "module": "" }, { "name": "/-- Construct a `BitVec w` from a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "ofFin ::", "module": "" }, { "name": "/-- Interpret a bitvector as a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "toFin : Fin (hPow 2 w)", "module": "" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Hidden.List", "content": "inductive List (Ξ± : Type u) where\n | nil : List Ξ±\n | cons : Ξ± β†’ List Ξ± β†’ List Ξ±" }, { "name": "Hidden.List.reverse", "content": "def reverse {Ξ± : Type u} (as : List Ξ±) : List Ξ± :=\n match as with\n | nil => nil\n | cons a as' => reverse as' ++ cons a nil" }, { "name": "Hidden.List.Palindrome", "content": "inductive Palindrome {Ξ± : Type} : List Ξ± β†’ Prop where\n | nil : Palindrome nil\n | single (x : Ξ±) : Palindrome (cons x nil)\n | sandwich (x : Ξ±) (xs : List Ξ±)\n : Palindrome xs β†’ Palindrome (cons x xs ++ cons x nil)" } ]
[ { "name": "Hidden.List.nil_append", "content": "theorem nil_append (as : List Ξ±) : nil ++ as = as" }, { "name": "Hidden.List.cons_append", "content": "theorem cons_append (a : Ξ±) (as bs : List Ξ±)\n : (cons a as) ++ bs = cons a (as ++ bs)" }, { "name": "Hidden.List.append_assoc", "content": "theorem append_assoc (as bs cs : List Ξ±)\n : (as ++ bs) ++ cs = as ++ (bs ++ cs)" } ]
namespace Hidden inductive List (Ξ± : Type u) where | nil : List Ξ± | cons : Ξ± β†’ List Ξ± β†’ List Ξ± namespace List def reverse {Ξ± : Type u} (as : List Ξ±) : List Ξ± := match as with | nil => nil | cons a as' => reverse as' ++ cons a nil inductive Palindrome {Ξ± : Type} : List Ξ± β†’ Prop where | nil : Palindrome nil | single (x : Ξ±) : Palindrome (cons x nil) | sandwich (x : Ξ±) (xs : List Ξ±) : Palindrome xs β†’ Palindrome (cons x xs ++ cons x nil) namespace Palindrome
theorem Palindrome_app_rev {Ξ± : Type} (l : List Ξ±) : Palindrome (l ++ reverse l) :=
:= by induction l with | nil => rw [nil_append, reverse]; exact nil | cons x xs ih => rw [cons_append, reverse, ←append_assoc, ←cons_append] apply sandwich x exact ih
2
6
false
Semantics
284
Hidden.Nat.mul_assoc
theorem mul_assoc (m n k : Nat) : m * n * k = m * (n * k)
lean-formal-reasoning-program
Frap/Inductive.lean
[]
[ { "name": "structure BitVec (w : Nat) where", "module": "" }, { "name": "/-- Construct a `BitVec w` from a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "ofFin ::", "module": "" }, { "name": "/-- Interpret a bitvector as a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "toFin : Fin (hPow 2 w)", "module": "" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Hidden.Nat", "content": "inductive Nat where\n | zero : Nat\n | succ : Nat β†’ Nat" }, { "name": "Hidden.Nat.add", "content": "def add (m n : Nat) : Nat :=\n match n with\n | zero => m\n | succ n' => succ (add m n')" } ]
[ { "name": "Hidden.Nat.add_succ", "content": "theorem add_succ (m n : Nat) : m + succ n = succ (m + n)" }, { "name": "Hidden.Nat.add_assoc", "content": "theorem add_assoc (m n k : Nat) : m + n + k = m + (n + k)" }, { "name": "Hidden.Nat.mul_succ", "content": "theorem mul_succ (m n : Nat) : m * succ n = add (m * n) m" }, { "name": "Hidden.Nat.add_infix", "content": "theorem add_infix (m n : Nat) : m.add n = m + n" } ]
section rewriting variable (Ξ± : Type) (a b c d : Ξ±) -- a, b, c, d are elements of some type /- ## Rewriting Recall our equality proof from last time. -/ example : a = b β†’ c = b β†’ c = d β†’ a = d := by intro hab hcb hcd apply Eq.trans . exact hab . apply Eq.trans . apply Eq.symm exact hcb . exact hcd /- Notice that in each subgoal, we are attempting to use a hypothesis by way of an equality property. For example, we invoke the transitive property on `a = d` so that we can use the assumption `a = b` and be left with `b = d` to prove. In effect, we are substituting `b` for `a` in the goal. This substitution operation can be seen as rewriting some term in the goal with another, via an equality in the hypothesis. This rewriting operation is so common that Lean provides a `rw` tactic to do so. It replaces equals for equals, which could be an equality (`=`) or equivalence (`↔`). Be default, it rewrites the left-hand side with the right-hand side. For right-to-left rewriting, a left arrow needs to be indicated before the hypothesis (`←`, typed with `\<-` shortcut) . -/ example : a = b β†’ c = b β†’ c = d β†’ a = d := by intro hab hcb hcd rw [hab] rw [← hcd] rw [hcb] end rewriting /- ## reflexivity tactic One of the most powerful tactics is the _reflexivity_ tactic, written `rfl` in Lean. It will attempt to conclude that both sides of an equality goal is indeed equal, up to some trivial computation, such as expansion of definitions and function applications. -/ example : 2 + 5 = 7 := by rfl example : Β¬ Even = 3 := by intro h sorry namespace Hidden inductive Nat where | zero : Nat | succ : Nat β†’ Nat namespace Nat def add (m n : Nat) : Nat := match n with | zero => m | succ n' => succ (add m n') def mul (m n : Nat) : Nat := match n with | zero => zero | succ n' => add (mul m n') m instance : Add Nat where add := add instance : Mul Nat where mul := mul end Nat end Hidden section opendemo open Nat end opendemo namespace Hidden namespace Nat end Nat end Hidden namespace Hidden namespace Nat
theorem mul_assoc (m n k : Nat) : m * n * k = m * (n * k) :=
:= by induction k with | zero => rfl | succ k' ih => rw [mul_succ, mul_succ, ih, add_infix, add_infix] have nat_distrib (m n k : Nat) : m * n + m * k = m * (n + k) := by -- distributive property from left induction k with | zero => rfl | succ k' ih => rw [mul_succ, add_succ, mul_succ, add_infix, add_infix, ← add_assoc, ih] rw [nat_distrib]
2
6
false
Semantics
285
permutation_cons_app
theorem permutation_cons_app (l l₁ lβ‚‚ : List Ξ±) : Permutation l (l₁ ++ lβ‚‚) β†’ Permutation (a :: l) (l₁ ++ a :: lβ‚‚)
lean-formal-reasoning-program
Frap/Sort.lean
[]
[ { "name": "List", "module": "Init.Prelude" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "append_assoc", "content": "theorem append_assoc (as bs cs : List Ξ±)\n : (as ++ bs) ++ cs = as ++ (bs ++ cs)" } ]
[ { "name": "Permutation", "content": "inductive Permutation {Ξ± : Type} : List Ξ± β†’ List Ξ± β†’ Prop :=\n | perm_nil : Permutation [] []\n | perm_skip x l l'\n : Permutation l l' β†’ Permutation (x::l) (x::l')\n | perm_swap x y l : Permutation (y::x::l) (x::y::l)\n | perm_trans l l' l''\n : Permutation l l' β†’ Permutation l' l''\n β†’ Permutation l l''" } ]
[ { "name": "permutation_refl", "content": "theorem permutation_refl (l : List Ξ±) : Permutation l l" }, { "name": "permutation_symm", "content": "theorem permutation_symm (l l' : List Ξ±)\n : Permutation l l' β†’ Permutation l' l" }, { "name": "permutation_app_head", "content": "theorem permutation_app_head (l tl tl' : List Ξ±)\n : Permutation tl tl' β†’ Permutation (l++tl) (l++tl')" }, { "name": "permutation_cons_append", "content": "theorem permutation_cons_append (l : List Ξ±) x\n : Permutation (x :: l) (l ++ [x])" } ]
inductive Permutation {Ξ± : Type} : List Ξ± β†’ List Ξ± β†’ Prop := | perm_nil : Permutation [] [] | perm_skip x l l' : Permutation l l' β†’ Permutation (x::l) (x::l') | perm_swap x y l : Permutation (y::x::l) (x::y::l) | perm_trans l l' l'' : Permutation l l' β†’ Permutation l' l'' β†’ Permutation l l'' open Permutation
theorem permutation_cons_app (l l₁ lβ‚‚ : List Ξ±) : Permutation l (l₁ ++ lβ‚‚) β†’ Permutation (a :: l) (l₁ ++ a :: lβ‚‚) :=
:= by intro h -- a :: l -- a :: (l₁ ++ lβ‚‚) -- l₁ ++ lβ‚‚ ++ [a] -- l₁ ++ (lβ‚‚ ++ [a]) -- l₁ ++ a :: lβ‚‚ apply perm_trans . apply perm_skip; exact h . apply perm_trans . apply permutation_cons_append . rw [List.append_assoc] apply permutation_app_head apply permutation_symm apply permutation_cons_append
2
7
false
Semantics
286
TM.soundness
theorem soundness t t' T : HasType t T β†’ multistep t t' β†’ Β¬ stuck t'
lean-formal-reasoning-program
Frap/Types.lean
[ "import Frap.SmallStep" ]
[ { "name": "And", "module": "Init.Prelude" } ]
[ { "name": "syntax term \"==>\" term : term", "content": "syntax term \"==>\" term : term\n\nsyntax term \"~~>\" term : term\n\nsyntax term \"~~>*\" term : term\n\nsyntax:30 term \" =[ \" imp \" ]=> \" term : term\n\nsyntax term \"!->\" term \"; \" term : term\n\nsyntax:36 term \"<<->>\" term : term" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$t:term ==> $n:term) => `(Eval $t $n)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$t₁:term ~~> $tβ‚‚:term) => `(Step $t₁ $tβ‚‚)\n\nexample :\n p\n (p (c 1) (c 3))\n (p (c 2) (c 4))\n ~~>\n p\n (c 4)\n (p (c 2) (c 4)) := by admit /- proof elided -/" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$t₁:term ~~>* $tβ‚‚:term) => `(Multi Step $t₁ $tβ‚‚)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$p <<->> $q) => `($p ->> $q ∧ $q ->> $p)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|{*$p*} $c {*$q*}) => `(valid_hoare_triple $p $c $q)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$st =[ $c ]=> $st') => `(CEval <{$c}> $st $st')" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$x:term !-> $a:term ; $st) => `(update $st $x $a)\n\nexample : empty =[\n x := 2;\n if (x <= 1) then y := 3 else z := 4 end\n ]=> (z !-> 4; x !-> 2; empty) := by admit /- proof elided -/" }, { "name": "Tm", "content": "inductive Tm : Type :=\n | tru : Tm\n | fls : Tm\n | ite : Tm β†’ Tm β†’ Tm β†’ Tm\n | zro : Tm\n | scc : Tm β†’ Tm\n | prd : Tm β†’ Tm\n | iszero : Tm β†’ Tm" }, { "name": "Step", "content": "inductive Step : Tm β†’ Tm β†’ Prop :=\n | st_ifTrue t₁ tβ‚‚ : Step (ite tru t₁ tβ‚‚) t₁\n | st_ifFalse t₁ tβ‚‚ : Step (ite fls t₁ tβ‚‚) tβ‚‚\n | st_if c c' t₁ tβ‚‚ :\n Step c c' β†’ Step (ite c t₁ tβ‚‚) (ite c' t₁ tβ‚‚)\n | st_succ t₁ t₁' : Step t₁ t₁' β†’ Step (scc t₁) (scc t₁')\n | st_pred0 : Step (prd zro) zro\n | st_predSucc v : NValue v β†’ Step (prd (scc v)) v\n | st_pred t₁ t₁' : Step t₁ t₁' β†’ Step (prd t₁) (prd t₁')\n | st_iszero0 : Step (iszero zro) tru\n | st_iszeroSucc v : NValue v β†’ Step (iszero (scc v)) fls\n | st_iszero t₁ t₁' :\n Step t₁ t₁' β†’ Step (iszero t₁) (iszero t₁')" }, { "name": "NValue", "content": "inductive NValue : Tm β†’ Prop :=\n | nv_0 : NValue zro\n | nv_succ t : NValue t β†’ NValue (scc t)" }, { "name": "Tm", "content": "inductive Tm : Type :=\n | c : Nat β†’ Tm \n | p : Tm β†’ Tm β†’ Tm " }, { "name": "normal_form", "content": "def normal_form {X : Type} (R : relation X) (t : X) : Prop := Β¬βˆƒt', R t t'" }, { "name": "relation", "content": "def relation (X : Type) := X β†’ X β†’ Prop" }, { "name": "BValue", "content": "inductive BValue : Tm β†’ Prop :=\n | bv_true : BValue tru\n | bv_false : BValue fls" }, { "name": "And", "content": "inductive And : Prop β†’ Prop β†’ Prop where\n | intro : a β†’ b β†’ And a b" }, { "name": "Ty", "content": "inductive Ty : Type :=\n | bool : Ty\n | nat : Ty" }, { "name": "HasType", "content": "inductive HasType : Tm β†’ Ty β†’ Prop :=\n | t_true : HasType tru bool\n | t_false : HasType fls bool\n | t_if t₁ tβ‚‚ t₃ T :\n HasType t₁ bool β†’ HasType tβ‚‚ T β†’ HasType t₃ T\n β†’ HasType (ite t₁ tβ‚‚ t₃) T\n | t_0 : HasType zro nat\n | t_succ t₁ : HasType t₁ nat β†’ HasType (scc t₁) nat\n | t_pred t₁ : HasType t₁ nat β†’ HasType (prd t₁) nat\n | t_iszero t₁ : HasType t₁ nat β†’ HasType (iszero t₁) bool" }, { "name": "Multi", "content": "inductive Multi {X : Type} (R : relation X) : relation X :=\n | multi_refl x : Multi R x x\n | multi_step x y z : R x y β†’ Multi R y z β†’ Multi R x z" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "TM.Tm", "content": "inductive Tm : Type :=\n | tru : Tm\n | fls : Tm\n | ite : Tm β†’ Tm β†’ Tm β†’ Tm\n | zro : Tm\n | scc : Tm β†’ Tm\n | prd : Tm β†’ Tm\n | iszero : Tm β†’ Tm" }, { "name": "TM.BValue", "content": "inductive BValue : Tm β†’ Prop :=\n | bv_true : BValue tru\n | bv_false : BValue fls" }, { "name": "TM.NValue", "content": "inductive NValue : Tm β†’ Prop :=\n | nv_0 : NValue zro\n | nv_succ t : NValue t β†’ NValue (scc t)" }, { "name": "TM.value", "content": "abbrev value (t : Tm) := BValue t ∨ NValue t" }, { "name": "TM.Step", "content": "inductive Step : Tm β†’ Tm β†’ Prop :=\n | st_ifTrue t₁ tβ‚‚ : Step (ite tru t₁ tβ‚‚) t₁\n | st_ifFalse t₁ tβ‚‚ : Step (ite fls t₁ tβ‚‚) tβ‚‚\n | st_if c c' t₁ tβ‚‚ :\n Step c c' β†’ Step (ite c t₁ tβ‚‚) (ite c' t₁ tβ‚‚)\n | st_succ t₁ t₁' : Step t₁ t₁' β†’ Step (scc t₁) (scc t₁')\n | st_pred0 : Step (prd zro) zro\n | st_predSucc v : NValue v β†’ Step (prd (scc v)) v\n | st_pred t₁ t₁' : Step t₁ t₁' β†’ Step (prd t₁) (prd t₁')\n | st_iszero0 : Step (iszero zro) tru\n | st_iszeroSucc v : NValue v β†’ Step (iszero (scc v)) fls\n | st_iszero t₁ t₁' :\n Step t₁ t₁' β†’ Step (iszero t₁) (iszero t₁')" }, { "name": "TM.step_normal_form", "content": "abbrev step_normal_form := normal_form Step" }, { "name": "TM.stuck", "content": "def stuck (t: Tm) : Prop :=\n step_normal_form t ∧ Β¬ value t\n\n/-\nexercise (2-star)\n-/\nexample : βˆƒ t, stuck t :=" }, { "name": "TM.Ty", "content": "inductive Ty : Type :=\n | bool : Ty\n | nat : Ty" }, { "name": "TM.HasType", "content": "inductive HasType : Tm β†’ Ty β†’ Prop :=\n | t_true : HasType tru bool\n | t_false : HasType fls bool\n | t_if t₁ tβ‚‚ t₃ T :\n HasType t₁ bool β†’ HasType tβ‚‚ T β†’ HasType t₃ T\n β†’ HasType (ite t₁ tβ‚‚ t₃) T\n | t_0 : HasType zro nat\n | t_succ t₁ : HasType t₁ nat β†’ HasType (scc t₁) nat\n | t_pred t₁ : HasType t₁ nat β†’ HasType (prd t₁) nat\n | t_iszero t₁ : HasType t₁ nat β†’ HasType (iszero t₁) bool" }, { "name": "TM.multistep", "content": "abbrev multistep := Multi Step" } ]
[ { "name": "TM.bool_canonical", "content": "theorem bool_canonical t : HasType t bool β†’ value t β†’ BValue t" }, { "name": "TM.nat_canonical", "content": "theorem nat_canonical t : HasType t nat β†’ value t β†’ NValue t" }, { "name": "TM.progress", "content": "theorem progress t T\n : HasType t T β†’ value t ∨ βˆƒ t', Step t t'" }, { "name": "TM.preservation", "content": "theorem preservation t t' T\n : HasType t T β†’ Step t t' β†’ HasType t' T" } ]
import Frap.SmallStep namespace TM inductive Tm : Type := | tru : Tm | fls : Tm | ite : Tm β†’ Tm β†’ Tm β†’ Tm | zro : Tm | scc : Tm β†’ Tm | prd : Tm β†’ Tm | iszero : Tm β†’ Tm open Tm inductive BValue : Tm β†’ Prop := | bv_true : BValue tru | bv_false : BValue fls inductive NValue : Tm β†’ Prop := | nv_0 : NValue zro | nv_succ t : NValue t β†’ NValue (scc t) open BValue open NValue abbrev value (t : Tm) := BValue t ∨ NValue t inductive Step : Tm β†’ Tm β†’ Prop := | st_ifTrue t₁ tβ‚‚ : Step (ite tru t₁ tβ‚‚) t₁ | st_ifFalse t₁ tβ‚‚ : Step (ite fls t₁ tβ‚‚) tβ‚‚ | st_if c c' t₁ tβ‚‚ : Step c c' β†’ Step (ite c t₁ tβ‚‚) (ite c' t₁ tβ‚‚) | st_succ t₁ t₁' : Step t₁ t₁' β†’ Step (scc t₁) (scc t₁') | st_pred0 : Step (prd zro) zro | st_predSucc v : NValue v β†’ Step (prd (scc v)) v | st_pred t₁ t₁' : Step t₁ t₁' β†’ Step (prd t₁) (prd t₁') | st_iszero0 : Step (iszero zro) tru | st_iszeroSucc v : NValue v β†’ Step (iszero (scc v)) fls | st_iszero t₁ t₁' : Step t₁ t₁' β†’ Step (iszero t₁) (iszero t₁') open Step abbrev step_normal_form := normal_form Step def stuck (t: Tm) : Prop := step_normal_form t ∧ Β¬ value t /- exercise (2-star) -/ example : βˆƒ t, stuck t := inductive Ty : Type := | bool : Ty | nat : Ty open Ty inductive HasType : Tm β†’ Ty β†’ Prop := | t_true : HasType tru bool | t_false : HasType fls bool | t_if t₁ tβ‚‚ t₃ T : HasType t₁ bool β†’ HasType tβ‚‚ T β†’ HasType t₃ T β†’ HasType (ite t₁ tβ‚‚ t₃) T | t_0 : HasType zro nat | t_succ t₁ : HasType t₁ nat β†’ HasType (scc t₁) nat | t_pred t₁ : HasType t₁ nat β†’ HasType (prd t₁) nat | t_iszero t₁ : HasType t₁ nat β†’ HasType (iszero t₁) bool open HasType example -- `⊒ if false then 0 else (succ 0) ∈ nat` : HasType (ite fls zro (scc zro)) nat := by apply t_if . apply t_false . apply t_0 . apply t_succ apply t_0 /- It's important to realize that the typing relation is a _conservative_ (or _static_) approximation: it does not consider what happens when the term is reduced. In particular, it does not calculate the type of its normal form. -/ example -- `⊒ if false then zero else true βˆ‰ bool` : Β¬ HasType (ite fls zro tru) bool := by intro contra cases contra rename_i contra _ cases contra /- exercise (1-star) -/ example t : HasType (scc t) nat β†’ HasType t nat := by intro ht cases ht assumption abbrev multistep := Multi Step
theorem soundness t t' T : HasType t T β†’ multistep t t' β†’ Β¬ stuck t' :=
:= by intro hT P induction P with (intro contra; obtain ⟨R, S⟩ := contra) | multi_refl => cases (progress _ _ hT) . -- value simp [*] at * . -- step simp [step_normal_form, normal_form, *] at * | multi_step => rename_i ih; apply ih . apply preservation . apply hT . assumption . unfold stuck; constructor <;> assumption
4
26
false
Semantics
287
CImp.par_body_n
theorem par_body_n n st : st x = 0 ∧ st y = 0 β†’ βˆƒ st', Multi CStep (par_loop, st) (par_loop, st') ∧ st' x = n ∧ st' y = 0
lean-formal-reasoning-program
Frap/SmallStepImp.lean
[ "import Frap.SmallStep", "import Frap.Equiv" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" }, { "name": "And", "module": "Init.Prelude" } ]
[ { "name": "syntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : im", "content": "syntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : imp" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|true) => `(Bool.true)\n | `(term|false) => `(Bool.false)\n | `(term|<{$x}>) => `(imp|$x)\n | `(imp|$n:num) => `(a_num $n)\n | `(imp|$s:str) => `(a_id $s)\n | `(imp|$x + $y) => `(a_plus <{$x}> <{$y}>)\n | `(imp|$x - $y) => `(a_minus <{$x}> <{$y}>)\n | `(imp|$x * $y) => `(a_mult <{$x}> <{$y}>)\n | `(imp|true) => `(b_true)\n | `(imp|false) => `(b_false)\n | `(imp|$x = $y) => `(b_eq <{$x}> <{$y}>)\n | `(imp|$x != $y) => `(b_neq <{$x}> <{$y}>)\n | `(imp|$x <= $y) => `(b_le <{$x}> <{$y}>)\n | `(imp|!$x) => `(b_not <{$x}>)\n | `(imp|$x && $y) => `(b_and <{$x}> <{$y}>)\n | `(imp|$x || $y) => `(b_or <{$x}> <{$y}>)\n | `(imp|($x)) => `(<{$x}>)\n | `(imp|$x:ident) => `(a_id $(Lean.quote (toString x.getId)))\n | `(imp|<[$t:term]>) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(imp|skip) => `(c_skip)\n | `(imp|$x:str := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$x:ident := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$c1 ; $c2) => `(c_seq <{$c1}> <{$c2}>)\n | `(imp|if $b then $c1 else $c2 end) => `(c_if <{$b}> <{$c1}> <{$c2}>)\n | `(imp|while $b do $c end) => `(c_while <{$b}> <{$c}>)" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_id : String β†’ AExp \n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "State", "content": "abbrev State := String β†’ Nat" }, { "name": "BExp", "content": "inductive BExp where\n | b_true : BExp\n | b_false : BExp\n | b_eq : AExp β†’ AExp β†’ BExp\n | b_neq : AExp β†’ AExp β†’ BExp\n | b_le : AExp β†’ AExp β†’ BExp\n | b_not : BExp β†’ BExp\n | b_and : BExp β†’ BExp β†’ BExp\n | b_or : BExp β†’ BExp β†’ BExp" }, { "name": "x", "content": "abbrev x := \"x\"" }, { "name": "Com", "content": "inductive Com :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com" }, { "name": "empty", "content": "def empty : State := fun _ => 0" }, { "name": "Multi", "content": "inductive Multi {X : Type} (R : relation X) : relation X :=\n | multi_refl x : Multi R x x\n | multi_step x y z : R x y β†’ Multi R y z β†’ Multi R x z" }, { "name": "relation", "content": "def relation (X : Type) := X β†’ X β†’ Prop" }, { "name": "update", "content": "def update (st : State) (k : String) (v : Nat) : State :=\n fun x => if x == k then v else st x" }, { "name": "y", "content": "abbrev y := \"y\"" }, { "name": "And", "content": "inductive And : Prop β†’ Prop β†’ Prop where\n | intro : a β†’ b β†’ And a b" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "AVal", "content": "inductive AVal : AExp β†’ Prop :=\n | av_num : βˆ€ n, AVal (a_num n)" }, { "name": "AStep", "content": "inductive AStep (st : State) : AExp β†’ AExp β†’ Prop :=\n | as_id : βˆ€ v, AStep st (a_id v) (a_num (st v))\n | as_plus1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ AStep st (a_plus a₁ aβ‚‚) (a_plus a₁' aβ‚‚)\n | as_plus2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ AStep st (a_plus v₁ aβ‚‚) (a_plus v₁ aβ‚‚')\n | as_plus : βˆ€ (v₁ vβ‚‚ : Nat),\n AStep st (a_plus (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ + vβ‚‚))\n | as_minus1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ AStep st (a_minus a₁ aβ‚‚) (a_minus a₁' aβ‚‚)\n | as_minus2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ AStep st (a_minus v₁ aβ‚‚) (a_minus v₁ aβ‚‚')\n | as_minus : βˆ€ (v₁ vβ‚‚ : Nat),\n AStep st (a_minus (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ - vβ‚‚))\n | as_mult1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ AStep st (a_mult a₁ aβ‚‚) (a_mult a₁' aβ‚‚)\n | as_mult2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ AStep st (a_mult v₁ aβ‚‚) (a_mult v₁ aβ‚‚')\n | as_mult : βˆ€ (v₁ vβ‚‚ : Nat),\n AStep st (a_mult (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ * vβ‚‚))" }, { "name": "BStep", "content": "inductive BStep (st : State) : BExp β†’ BExp β†’ Prop :=\n | bs_eq1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ BStep st (b_eq a₁ aβ‚‚) (b_eq a₁' aβ‚‚)\n | bs_eq2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ BStep st (b_eq v₁ aβ‚‚) (b_eq v₁ aβ‚‚')\n | bs_eq : βˆ€ (v₁ vβ‚‚ : Nat),\n BStep st (b_eq (a_num v₁) (a_num vβ‚‚))\n (if v₁ == vβ‚‚ then b_true else b_false)\n | bs_neq1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ BStep st (b_neq a₁ aβ‚‚) (b_neq a₁' aβ‚‚)\n | bs_neq2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ BStep st (b_neq v₁ aβ‚‚) (b_neq v₁ aβ‚‚')\n | bs_neq : βˆ€ (v₁ vβ‚‚ : Nat),\n BStep st (b_neq (a_num v₁) (a_num vβ‚‚))\n (if v₁ != vβ‚‚ then b_true else b_false)\n | bs_le1 : βˆ€ a₁ a₁' aβ‚‚,\n AStep st a₁ a₁'\n β†’ BStep st (b_le a₁ aβ‚‚) (b_le a₁' aβ‚‚)\n | bs_le2 : βˆ€ v₁ aβ‚‚ aβ‚‚',\n AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚'\n β†’ BStep st (b_le v₁ aβ‚‚) (b_le v₁ aβ‚‚')\n | bs_le : βˆ€ (v₁ vβ‚‚ : Nat),\n BStep st (b_le (a_num v₁) (a_num vβ‚‚))\n (if v₁ <= vβ‚‚ then b_true else b_false)\n | bs_notStep : βˆ€ b₁ b₁',\n BStep st b₁ b₁'\n β†’ BStep st (b_not b₁) (b_not b₁')\n | bs_notTrue : BStep st (b_not b_true) b_false\n | bs_notFalse : BStep st (b_not b_false) b_true\n | bs_andStep : βˆ€ b₁ b₁' bβ‚‚,\n BStep st b₁ b₁'\n β†’ BStep st (b_and b₁ bβ‚‚) (b_and b₁' bβ‚‚)\n | bs_andFalse : βˆ€ bβ‚‚,\n BStep st (b_and b_false bβ‚‚) b_false\n | bs_andTrueStep : βˆ€ bβ‚‚ bβ‚‚',\n BStep st bβ‚‚ bβ‚‚'\n β†’ BStep st (b_and b_true bβ‚‚) (b_and b_true bβ‚‚')\n | bs_andTrueTrue :\n BStep st (b_and b_true b_true) b_true\n | bs_andTrueFalse :\n BStep st (b_and b_true b_false) b_false\n | bs_orStep : βˆ€ b₁ b₁' bβ‚‚,\n BStep st b₁ b₁'\n β†’ BStep st (b_or b₁ bβ‚‚) (b_or b₁' bβ‚‚)\n | bs_orTrue : βˆ€ bβ‚‚,\n BStep st (b_or b_true bβ‚‚) b_true\n | bs_orFalseStep : βˆ€ bβ‚‚ bβ‚‚',\n BStep st bβ‚‚ bβ‚‚'\n β†’ BStep st (b_or b_false bβ‚‚) (b_or b_false bβ‚‚')\n | bs_orFalseTrue :\n BStep st (b_or b_false b_true) b_true\n | bs_orFalseFalse :\n BStep st (b_or b_false b_false) b_false" }, { "name": "CStep", "content": "inductive CStep : (Com Γ— State) β†’ (Com Γ— State) β†’ Prop :=\n | cs_asgnStep : βˆ€ st v a₁ a₁',\n AStep st a₁ a₁'\n β†’ CStep (c_asgn v a₁, st) (c_asgn v a₁', st)\n | cs_asgn : βˆ€ st v (n : Nat),\n CStep (c_asgn v (a_num n), st) (c_skip, x !-> n; st)\n | cs_seqStep : βˆ€ st c₁ c₁' st' cβ‚‚,\n CStep (c₁, st) (c₁', st')\n β†’ CStep (c_seq c₁ cβ‚‚, st) (c_seq c₁' cβ‚‚, st')\n | cs_seqFinish : βˆ€ st cβ‚‚,\n CStep (c_seq c_skip cβ‚‚, st) (cβ‚‚, st)\n | cs_ifStep : βˆ€ st b₁ b₁' c₁ cβ‚‚,\n BStep st b₁ b₁'\n β†’ CStep (c_if b₁ c₁ cβ‚‚, st) (c_if b₁' c₁ cβ‚‚, st)\n | cs_ifTrue : βˆ€ st c₁ cβ‚‚,\n CStep (c_if b_true c₁ cβ‚‚, st) (c₁, st)\n | cs_ifFalse : βˆ€ st c₁ cβ‚‚,\n CStep (c_if b_false c₁ cβ‚‚, st) (cβ‚‚, st)\n | cs_while : βˆ€ st b₁ c₁,\n CStep (c_while b₁ c₁, st)\n (c_if b₁ (c_seq c₁ (c_while b₁ c₁)) c_skip, st)" }, { "name": "CImp.Com", "content": "inductive Com : Type :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com\n | c_par : Com β†’ Com β†’ Com" }, { "name": "CImp.CStep", "content": "inductive CStep : (Com Γ— State) β†’ (Com Γ— State) β†’ Prop :=\n \n | cs_asgnStep : βˆ€ st v a₁ a₁',\n AStep st a₁ a₁'\n β†’ CStep (c_asgn v a₁, st) (c_asgn v a₁', st)\n | cs_asgn : βˆ€ st v (n : Nat),\n CStep (c_asgn v (a_num n), st) (c_skip, v !-> n; st)\n | cs_seqStep : βˆ€ st c₁ c₁' st' cβ‚‚,\n CStep (c₁, st) (c₁', st')\n β†’ CStep (c_seq c₁ cβ‚‚, st) (c_seq c₁' cβ‚‚, st')\n | cs_seqFinish : βˆ€ st cβ‚‚,\n CStep (c_seq c_skip cβ‚‚, st) (cβ‚‚, st)\n | cs_ifStep : βˆ€ st b₁ b₁' c₁ cβ‚‚,\n BStep st b₁ b₁'\n β†’ CStep (c_if b₁ c₁ cβ‚‚, st) (c_if b₁' c₁ cβ‚‚, st)\n | cs_ifTrue : βˆ€ st c₁ cβ‚‚,\n CStep (c_if b_true c₁ cβ‚‚, st) (c₁, st)\n | cs_ifFalse : βˆ€ st c₁ cβ‚‚,\n CStep (c_if b_false c₁ cβ‚‚, st) (cβ‚‚, st)\n | cs_while : βˆ€ st b₁ c₁,\n CStep (c_while b₁ c₁, st)\n (c_if b₁ (c_seq c₁ (c_while b₁ c₁)) c_skip, st)\n \n | cs_par1 : βˆ€ st c₁ c₁' cβ‚‚ st',\n CStep (c₁, st) (c₁', st')\n β†’ CStep (c_par c₁ cβ‚‚, st) (c_par c₁' cβ‚‚, st')\n | cs_par2 : βˆ€ st c₁ cβ‚‚ cβ‚‚' st',\n CStep (cβ‚‚, st) (cβ‚‚', st')\n β†’ CStep (c_par c₁ cβ‚‚, st) (c_par c₁ cβ‚‚', st')\n | cs_parDone : βˆ€ st,\n CStep (c_par c_skip c_skip, st) (c_skip, st)" }, { "name": "CImp.par_loop", "content": "def par_loop : Com :=\n c_par\n (c_asgn y (a_num 1))\n (c_while (b_eq (a_id y) (a_num 0))\n (c_asgn x (a_plus (a_id x) (a_num 1))))\n\n/-\nIn particular, it can terminate with `x` set to `0`.\n-/\n\nexample : βˆƒ st',\n Multi CStep (par_loop, empty) (c_skip, st')\n ∧ st' x = 0 :=" } ]
[ { "name": "CImp.par_body_n__Sn", "content": "theorem par_body_n__Sn n st\n : st x = n ∧ st y = 0\n β†’ Multi CStep (par_loop, st) (par_loop, x !-> n + 1; st)" } ]
import Frap.Equiv import Frap.SmallStep open Imp open AExp open BExp open Com open Multi inductive AVal : AExp β†’ Prop := | av_num : βˆ€ n, AVal (a_num n) inductive AStep (st : State) : AExp β†’ AExp β†’ Prop := | as_id : βˆ€ v, AStep st (a_id v) (a_num (st v)) | as_plus1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ AStep st (a_plus a₁ aβ‚‚) (a_plus a₁' aβ‚‚) | as_plus2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ AStep st (a_plus v₁ aβ‚‚) (a_plus v₁ aβ‚‚') | as_plus : βˆ€ (v₁ vβ‚‚ : Nat), AStep st (a_plus (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ + vβ‚‚)) | as_minus1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ AStep st (a_minus a₁ aβ‚‚) (a_minus a₁' aβ‚‚) | as_minus2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ AStep st (a_minus v₁ aβ‚‚) (a_minus v₁ aβ‚‚') | as_minus : βˆ€ (v₁ vβ‚‚ : Nat), AStep st (a_minus (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ - vβ‚‚)) | as_mult1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ AStep st (a_mult a₁ aβ‚‚) (a_mult a₁' aβ‚‚) | as_mult2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ AStep st (a_mult v₁ aβ‚‚) (a_mult v₁ aβ‚‚') | as_mult : βˆ€ (v₁ vβ‚‚ : Nat), AStep st (a_mult (a_num v₁) (a_num vβ‚‚)) (a_num (v₁ * vβ‚‚)) open AStep inductive BStep (st : State) : BExp β†’ BExp β†’ Prop := | bs_eq1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ BStep st (b_eq a₁ aβ‚‚) (b_eq a₁' aβ‚‚) | bs_eq2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ BStep st (b_eq v₁ aβ‚‚) (b_eq v₁ aβ‚‚') | bs_eq : βˆ€ (v₁ vβ‚‚ : Nat), BStep st (b_eq (a_num v₁) (a_num vβ‚‚)) (if v₁ == vβ‚‚ then b_true else b_false) | bs_neq1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ BStep st (b_neq a₁ aβ‚‚) (b_neq a₁' aβ‚‚) | bs_neq2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ BStep st (b_neq v₁ aβ‚‚) (b_neq v₁ aβ‚‚') | bs_neq : βˆ€ (v₁ vβ‚‚ : Nat), BStep st (b_neq (a_num v₁) (a_num vβ‚‚)) (if v₁ != vβ‚‚ then b_true else b_false) | bs_le1 : βˆ€ a₁ a₁' aβ‚‚, AStep st a₁ a₁' β†’ BStep st (b_le a₁ aβ‚‚) (b_le a₁' aβ‚‚) | bs_le2 : βˆ€ v₁ aβ‚‚ aβ‚‚', AVal v₁ β†’ AStep st aβ‚‚ aβ‚‚' β†’ BStep st (b_le v₁ aβ‚‚) (b_le v₁ aβ‚‚') | bs_le : βˆ€ (v₁ vβ‚‚ : Nat), BStep st (b_le (a_num v₁) (a_num vβ‚‚)) (if v₁ <= vβ‚‚ then b_true else b_false) | bs_notStep : βˆ€ b₁ b₁', BStep st b₁ b₁' β†’ BStep st (b_not b₁) (b_not b₁') | bs_notTrue : BStep st (b_not b_true) b_false | bs_notFalse : BStep st (b_not b_false) b_true | bs_andStep : βˆ€ b₁ b₁' bβ‚‚, BStep st b₁ b₁' β†’ BStep st (b_and b₁ bβ‚‚) (b_and b₁' bβ‚‚) | bs_andFalse : βˆ€ bβ‚‚, BStep st (b_and b_false bβ‚‚) b_false | bs_andTrueStep : βˆ€ bβ‚‚ bβ‚‚', BStep st bβ‚‚ bβ‚‚' β†’ BStep st (b_and b_true bβ‚‚) (b_and b_true bβ‚‚') | bs_andTrueTrue : BStep st (b_and b_true b_true) b_true | bs_andTrueFalse : BStep st (b_and b_true b_false) b_false | bs_orStep : βˆ€ b₁ b₁' bβ‚‚, BStep st b₁ b₁' β†’ BStep st (b_or b₁ bβ‚‚) (b_or b₁' bβ‚‚) | bs_orTrue : βˆ€ bβ‚‚, BStep st (b_or b_true bβ‚‚) b_true | bs_orFalseStep : βˆ€ bβ‚‚ bβ‚‚', BStep st bβ‚‚ bβ‚‚' β†’ BStep st (b_or b_false bβ‚‚) (b_or b_false bβ‚‚') | bs_orFalseTrue : BStep st (b_or b_false b_true) b_true | bs_orFalseFalse : BStep st (b_or b_false b_false) b_false open BStep inductive CStep : (Com Γ— State) β†’ (Com Γ— State) β†’ Prop := | cs_asgnStep : βˆ€ st v a₁ a₁', AStep st a₁ a₁' β†’ CStep (c_asgn v a₁, st) (c_asgn v a₁', st) | cs_asgn : βˆ€ st v (n : Nat), CStep (c_asgn v (a_num n), st) (c_skip, x !-> n; st) | cs_seqStep : βˆ€ st c₁ c₁' st' cβ‚‚, CStep (c₁, st) (c₁', st') β†’ CStep (c_seq c₁ cβ‚‚, st) (c_seq c₁' cβ‚‚, st') | cs_seqFinish : βˆ€ st cβ‚‚, CStep (c_seq c_skip cβ‚‚, st) (cβ‚‚, st) | cs_ifStep : βˆ€ st b₁ b₁' c₁ cβ‚‚, BStep st b₁ b₁' β†’ CStep (c_if b₁ c₁ cβ‚‚, st) (c_if b₁' c₁ cβ‚‚, st) | cs_ifTrue : βˆ€ st c₁ cβ‚‚, CStep (c_if b_true c₁ cβ‚‚, st) (c₁, st) | cs_ifFalse : βˆ€ st c₁ cβ‚‚, CStep (c_if b_false c₁ cβ‚‚, st) (cβ‚‚, st) | cs_while : βˆ€ st b₁ c₁, CStep (c_while b₁ c₁, st) (c_if b₁ (c_seq c₁ (c_while b₁ c₁)) c_skip, st) namespace CImp inductive Com : Type := | c_skip : Com | c_asgn : String β†’ AExp β†’ Com | c_seq : Com β†’ Com β†’ Com | c_if : BExp β†’ Com β†’ Com β†’ Com | c_while : BExp β†’ Com β†’ Com | c_par : Com β†’ Com β†’ Com open Com inductive CStep : (Com Γ— State) β†’ (Com Γ— State) β†’ Prop := | cs_asgnStep : βˆ€ st v a₁ a₁', AStep st a₁ a₁' β†’ CStep (c_asgn v a₁, st) (c_asgn v a₁', st) | cs_asgn : βˆ€ st v (n : Nat), CStep (c_asgn v (a_num n), st) (c_skip, v !-> n; st) | cs_seqStep : βˆ€ st c₁ c₁' st' cβ‚‚, CStep (c₁, st) (c₁', st') β†’ CStep (c_seq c₁ cβ‚‚, st) (c_seq c₁' cβ‚‚, st') | cs_seqFinish : βˆ€ st cβ‚‚, CStep (c_seq c_skip cβ‚‚, st) (cβ‚‚, st) | cs_ifStep : βˆ€ st b₁ b₁' c₁ cβ‚‚, BStep st b₁ b₁' β†’ CStep (c_if b₁ c₁ cβ‚‚, st) (c_if b₁' c₁ cβ‚‚, st) | cs_ifTrue : βˆ€ st c₁ cβ‚‚, CStep (c_if b_true c₁ cβ‚‚, st) (c₁, st) | cs_ifFalse : βˆ€ st c₁ cβ‚‚, CStep (c_if b_false c₁ cβ‚‚, st) (cβ‚‚, st) | cs_while : βˆ€ st b₁ c₁, CStep (c_while b₁ c₁, st) (c_if b₁ (c_seq c₁ (c_while b₁ c₁)) c_skip, st) | cs_par1 : βˆ€ st c₁ c₁' cβ‚‚ st', CStep (c₁, st) (c₁', st') β†’ CStep (c_par c₁ cβ‚‚, st) (c_par c₁' cβ‚‚, st') | cs_par2 : βˆ€ st c₁ cβ‚‚ cβ‚‚' st', CStep (cβ‚‚, st) (cβ‚‚', st') β†’ CStep (c_par c₁ cβ‚‚, st) (c_par c₁ cβ‚‚', st') | cs_parDone : βˆ€ st, CStep (c_par c_skip c_skip, st) (c_skip, st) open CStep def par_loop : Com := c_par (c_asgn y (a_num 1)) (c_while (b_eq (a_id y) (a_num 0)) (c_asgn x (a_plus (a_id x) (a_num 1)))) /- In particular, it can terminate with `x` set to `0`. -/ example : βˆƒ st', Multi CStep (par_loop, empty) (c_skip, st') ∧ st' x = 0 :=
theorem par_body_n n st : st x = 0 ∧ st y = 0 β†’ βˆƒ st', Multi CStep (par_loop, st) (par_loop, st') ∧ st' x = n ∧ st' y = 0 :=
:= by intro h obtain ⟨hx, hy⟩ := h induction n with | zero => exists st apply And.intro . apply multi_refl . apply And.intro . apply hx . apply hy | succ n' hn' => obtain ⟨st', ⟨h', ⟨hx', hy'⟩⟩⟩ := hn' constructor apply And.intro . apply multi_trans . apply h' . apply par_body_n__Sn . apply And.intro . exact hx' . exact hy' . apply And.intro . rfl . exact hy'
3
24
false
Semantics
288
Imp.Hoare.hoare_if
theorem hoare_if P Q b c₁ cβ‚‚ : {* fun st => P st ∧ beval st b *} c₁ {* Q *} β†’ {* fun st => P st ∧ Β¬(beval st b) *} cβ‚‚ {* Q *} β†’ {* P *} c_if b c₁ cβ‚‚ {* Q *}
lean-formal-reasoning-program
Frap/Hoare.lean
[ "import Frap.Trans" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "syntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : im", "content": "syntax:21 \"if\" imp:20 \"then\" imp:20 \"else\" imp:20 \"end\" : imp\n\nsyntax \"false\" : imp\n\nsyntax \"false\" : term\n\nsyntax \"true\" : imp\n\nsyntax \"true\" : term\n\nsyntax \"<{\" imp \"}>\" : term\n\nsyntax:30 \"{*\" term \"*}\" term \"{*\" term \"*}\" : term\n\nsyntax \"<[\" term \"]>\" : imp" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|true) => `(Bool.true)\n | `(term|false) => `(Bool.false)\n | `(term|<{$x}>) => `(imp|$x)\n | `(imp|$n:num) => `(a_num $n)\n | `(imp|$s:str) => `(a_id $s)\n | `(imp|$x + $y) => `(a_plus <{$x}> <{$y}>)\n | `(imp|$x - $y) => `(a_minus <{$x}> <{$y}>)\n | `(imp|$x * $y) => `(a_mult <{$x}> <{$y}>)\n | `(imp|true) => `(b_true)\n | `(imp|false) => `(b_false)\n | `(imp|$x = $y) => `(b_eq <{$x}> <{$y}>)\n | `(imp|$x != $y) => `(b_neq <{$x}> <{$y}>)\n | `(imp|$x <= $y) => `(b_le <{$x}> <{$y}>)\n | `(imp|!$x) => `(b_not <{$x}>)\n | `(imp|$x && $y) => `(b_and <{$x}> <{$y}>)\n | `(imp|$x || $y) => `(b_or <{$x}> <{$y}>)\n | `(imp|($x)) => `(<{$x}>)\n | `(imp|$x:ident) => `(a_id $(Lean.quote (toString x.getId)))\n | `(imp|<[$t:term]>) => pure t" }, { "name": "macro_rules", "content": "macro_rules\n | `(imp|skip) => `(c_skip)\n | `(imp|$x:str := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$x:ident := $y) => `(c_asgn $x <{$y}>)\n | `(imp|$c1 ; $c2) => `(c_seq <{$c1}> <{$c2}>)\n | `(imp|if $b then $c1 else $c2 end) => `(c_if <{$b}> <{$c1}> <{$c2}>)\n | `(imp|while $b do $c end) => `(c_while <{$b}> <{$c}>)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|$p <<->> $q) => `($p ->> $q ∧ $q ->> $p)" }, { "name": "macro_rules", "content": "macro_rules\n | `(term|{*$p*} $c {*$q*}) => `(valid_hoare_triple $p $c $q)" }, { "name": "x", "content": "abbrev x := \"x\"" }, { "name": "Com", "content": "inductive Com : Type :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com\n | c_par : Com β†’ Com β†’ Com " }, { "name": "beval", "content": "def beval (st : State) (b : BExp) : Bool :=\n match b with\n | b_true => true\n | b_false => false\n | b_eq a₁ aβ‚‚ => (aeval st a₁) == (aeval st aβ‚‚)\n | b_neq a₁ aβ‚‚ => (aeval st a₁) != (aeval st aβ‚‚)\n | b_le a₁ aβ‚‚ => (aeval st a₁) <= (aeval st aβ‚‚)\n | b_not b₁ => not (beval st b₁)\n | b_and b₁ bβ‚‚ => and (beval st b₁) (beval st bβ‚‚)\n | b_or b₁ bβ‚‚ => or (beval st b₁) (beval st bβ‚‚)\n\nexample : aeval (update empty x 5)\n <{3 + x * 2}>\n \n = 13 := by admit /- proof elided -/" }, { "name": "empty", "content": "def empty : State := fun _ => 0" }, { "name": "State", "content": "abbrev State := String β†’ Nat" }, { "name": "y", "content": "abbrev y := \"y\"" }, { "name": "z", "content": "abbrev z := \"z\"" }, { "name": "aeval", "content": "def aeval (st : State) (a : AExp) : Nat :=\n match a with\n | a_num n => n\n | a_id x => st x\n | a_plus a₁ aβ‚‚ => (aeval st a₁) + (aeval st aβ‚‚)\n | a_minus a₁ aβ‚‚ => (aeval st a₁) - (aeval st aβ‚‚)\n | a_mult a₁ aβ‚‚ => (aeval st a₁) * (aeval st aβ‚‚)" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_id : String β†’ AExp \n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "AExp", "content": "inductive AExp where\n | a_num : Nat β†’ AExp\n | a_plus : AExp β†’ AExp β†’ AExp\n | a_minus : AExp β†’ AExp β†’ AExp\n | a_mult : AExp β†’ AExp β†’ AExp" }, { "name": "update", "content": "def update (st : State) (k : String) (v : Nat) : State :=\n fun x => if x == k then v else st x" }, { "name": "BExp", "content": "inductive BExp where\n | b_true : BExp\n | b_false : BExp\n | b_eq : AExp β†’ AExp β†’ BExp\n | b_neq : AExp β†’ AExp β†’ BExp\n | b_le : AExp β†’ AExp β†’ BExp\n | b_not : BExp β†’ BExp\n | b_and : BExp β†’ BExp β†’ BExp\n | b_or : BExp β†’ BExp β†’ BExp" }, { "name": "Com", "content": "inductive Com :=\n | c_skip : Com\n | c_asgn : String β†’ AExp β†’ Com\n | c_seq : Com β†’ Com β†’ Com\n | c_if : BExp β†’ Com β†’ Com β†’ Com\n | c_while : BExp β†’ Com β†’ Com" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Imp.Hoare.Assertion", "content": "abbrev Assertion := State β†’ Prop" }, { "name": "Imp.Hoare.assert_implies", "content": "def assert_implies (P Q : Assertion) : Prop :=\n βˆ€ st, P st β†’ Q st" }, { "name": "Imp.Hoare.valid_hoare_triple", "content": "def valid_hoare_triple (P : Assertion) (c : Com) (Q : Assertion) : Prop :=\n βˆ€ st st', P st β†’ (st =[<[c]>]=> st') β†’ Q st'" } ]
[ { "name": "Imp.Hoare.hoare_asgn", "content": "theorem hoare_asgn Q x a :\n {* fun st => Q (st[x ↦ aeval st a]) *} c_asgn x a {* Q *}" }, { "name": "Imp.Hoare.hoare_consequence_pre", "content": "theorem hoare_consequence_pre P P' Q c :\n {* P' *} c {* Q *}\n β†’ P ->> P'\n β†’ {* P *} c {* Q *}" } ]
import Frap.Trans namespace Imp open AExp open BExp open Com open CEval namespace Hoare abbrev Assertion := State β†’ Prop def assert_implies (P Q : Assertion) : Prop := βˆ€ st, P st β†’ Q st infix:36 " ->> " => assert_implies def valid_hoare_triple (P : Assertion) (c : Com) (Q : Assertion) : Prop := βˆ€ st st', P st β†’ (st =[<[c]>]=> st') β†’ Q st'
theorem hoare_if P Q b c₁ cβ‚‚ : {* fun st => P st ∧ beval st b *} c₁ {* Q *} β†’ {* fun st => P st ∧ Β¬(beval st b) *} cβ‚‚ {* Q *} β†’ {* P *} c_if b c₁ cβ‚‚ {* Q *} :=
:= by intro hTrue hFalse st st' hPre hEval cases hEval . -- e_ifTrue rename_i hb hc₁ apply hTrue . constructor . exact hPre . exact hb . exact hc₁ . -- e_ifFalse rename_i hb hcβ‚‚ apply hFalse . constructor . exact hPre . simp [hb] . exact hcβ‚‚ example : -- { True } {* fun _ => True *} <{if x = 0 then y := 2 else y := x + 1 end}> -- { x ≀ y } {* fun st => st x <= st y *} := by apply hoare_if . apply hoare_consequence_pre . apply hoare_asgn . intro st _ simp [update] at * split <;> simp [*] . apply hoare_consequence_pre . apply hoare_asgn . intro st _ simp [update] split . simp [*] . unfold x omega
4
21
false
Semantics
289
Hidden.List.reverse_append
theorem reverse_append {Ξ± : Type u} (as bs : List Ξ±) : reverse (as ++ bs) = reverse bs ++ reverse as
lean-formal-reasoning-program
Frap/Exercises/IndProp.lean
[]
[ { "name": "structure BitVec (w : Nat) where", "module": "" }, { "name": "/-- Construct a `BitVec w` from a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "ofFin ::", "module": "" }, { "name": "/-- Interpret a bitvector as a number less than `2^w`.", "module": "" }, { "name": "O(1), because we use `Fin` as the internal representation of a bitvector. -/", "module": "" }, { "name": "toFin : Fin (hPow 2 w)", "module": "" } ]
[ { "name": "...", "content": "..." } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "Hidden.List", "content": "inductive List (Ξ± : Type u) where\n | nil : List Ξ±\n | cons : Ξ± β†’ List Ξ± β†’ List Ξ±" }, { "name": "Hidden.List.reverse", "content": "def reverse {Ξ± : Type u} (as : List Ξ±) : List Ξ± :=\n match as with\n | nil => nil\n | cons a as' => reverse as' ++ cons a nil" } ]
[ { "name": "Hidden.List.nil_append", "content": "theorem nil_append (as : List Ξ±) : nil ++ as = as" }, { "name": "Hidden.List.cons_append", "content": "theorem cons_append (a : Ξ±) (as bs : List Ξ±)\n : (cons a as) ++ bs = cons a (as ++ bs)" }, { "name": "Hidden.List.append_nil", "content": "theorem append_nil (as : List Ξ±) : as ++ nil = as" }, { "name": "Hidden.List.append_assoc", "content": "theorem append_assoc (as bs cs : List Ξ±)\n : (as ++ bs) ++ cs = as ++ (bs ++ cs)" } ]
namespace Hidden inductive List (Ξ± : Type u) where | nil : List Ξ± | cons : Ξ± β†’ List Ξ± β†’ List Ξ± namespace List def reverse {Ξ± : Type u} (as : List Ξ±) : List Ξ± := match as with | nil => nil | cons a as' => reverse as' ++ cons a nil
theorem reverse_append {Ξ± : Type u} (as bs : List Ξ±) : reverse (as ++ bs) = reverse bs ++ reverse as :=
:= by induction as with | nil => rw [nil_append, reverse, append_nil] | cons a as' ih => rw [cons_append, reverse, reverse, ih, append_assoc]
2
7
false
Semantics
290
and_associative
theorem and_associative (p q r : Prop) : (p ∧ q) ∧ r ↔ p ∧ (q ∧ r)
lean-formal-reasoning-program
Frap/Propositional.lean
[]
[ { "name": "Iff", "module": "Init.Core" } ]
[ { "name": "Iff", "content": "inductive Iff : Prop β†’ Prop β†’ Prop where\n | intro : (a β†’ b) β†’ (b β†’ a) β†’ Iff a b" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[ { "name": "and_commutative", "content": "theorem and_commutative (p q : Prop) : p ∧ q ↔ q ∧ p" } ]
import Mathlib.Computability.NFA import Mathlib.Data.FinEnum import Mathlib.Data.Rel import Mathlib.Data.Vector.Basic import Blase.AutoStructs.ForLean open Set open Mathlib open SetRel -- this is better because card is defeq to n instance (Ξ± : Type) : Inter (Language Ξ±) := ⟨Set.inter⟩ instance (Ξ± : Type) : Union (Language Ξ±) := ⟨Set.union⟩ /-- The set of `n`-tuples of bit vectors of an arbitrary width. -/ structure BitVecs (n : Nat) where w : Nat bvs : List.Vector (BitVec w) n def BitVecs.cast (bvs : BitVecs n) (h : n = n') : BitVecs n' := { w := bvs.w, bvs := h β–Έ bvs.bvs } abbrev BitVecs.empty : BitVecs n := ⟨0, List.Vector.replicate n .nil⟩ abbrev BitVecs.singleton {w : Nat} (bv : BitVec w) : BitVecs 1 := ⟨w, bv ::α΅₯ .nil⟩ abbrev BitVecs.pair {w : Nat} (bv1 bv2 : BitVec w) : BitVecs 2 := ⟨w, bv1 ::α΅₯ bv2 ::α΅₯ .nil⟩ /-- The set of `n`-tuples of bit vectors of an arbitrary width, encoded as a list of bit vectors of width `n`. The width of the encoded bit vectors is the length of the list. -/ abbrev BitVecs' (n : Nat) := List (BitVec n) @[simps] def dec (bvs' : BitVecs' n) : BitVecs n where w := bvs'.length bvs := List.Vector.ofFn fun k => BitVec.ofFn fun i => bvs'[i].getLsbD k @[simp]
theorem and_associative (p q r : Prop) : (p ∧ q) ∧ r ↔ p ∧ (q ∧ r) :=
:= by constructor . intro h cases h with | intro hpq hr => cases hpq with | intro hp hq => apply And.intro . exact hp . apply And.intro . exact hq . exact hr . intro h cases h with | intro hp hqr => cases hqr with | intro hq hr => apply And.intro . apply And.intro . exact hp . exact hq . exact hr /- ## Rewriting proof terms using previously proven results Often in our proof, we'll need to use the same tactic sequence as in a prior proof. Like in software development, duplicating the sequence results in duplicate code and can lead to maintenance problems. We can refer to an earlier propeosition by simply writing the name of the theorem or lemma of interest. This is similar to breaking down a large program into functions. First, if we have a previously proven result, we can apply that result directly in the `apply` tactic. -/ example (p q : Prop) : p ∧ q ↔ q ∧ p := by apply and_commutative /- We can even refer to asserted but unproven propositions. -/ example (p q r : Prop) : (p ∧ q) ∧ r ↔ p ∧ (q ∧ r) := by apply and_associative /- For nested proof terms, we can use the `rewrite` tactic, along with a list of identities (equivalences) to apply to the proof goal or a hypothesis. The syntax here is a bit complicated. We need to pass a configuration stating which occurrence(s) of the proof term we want to rewrite. An occurrence is a preorder position within the AST of the proof term, with 1 as the root (the entire proof term). You might need to do some trial-and-error to get the desired occurrence. Refer to the pop-up contextual guide for more information. -/ example (p q r : Prop) : (p ∧ q) ∧ r ↔ (q ∧ p) ∧ r := by apply Iff.intro . intro h rewrite (config := {occs := .pos [2]}) [and_commutative] at h assumption . intro h rewrite (config := {occs := .pos [2]}) [and_commutative] at h assumption
2
3
false
Semantics
291
While.WellTyped.some_ty
theorem WellTyped.some_ty {e ty} : e.ty = some ty β†’ WellTyped e ty
lean-hoare
Hoare/While/Types.lean
[ "import Hoare.While.Syntax" ]
[ { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.isSome", "module": "Init.Data.Option.Basic" } ]
[ { "name": "syntax num : nexpr", "content": "syntax num : nexpr\n\nsyntax \"if \" bexpr \" then \" com \" else \" com \" fi\" : com" }, { "name": "macro_rules", "content": "macro_rules\n| `([nexpr| $n:num]) => `(Expr.num $n)\n| `([nexpr| $x:ident]) => `(Expr.var $(Lean.quote x.getId.toString))\n| `([bexpr| true]) => `(Expr.bool Β«trueΒ»)\n| `([bexpr| false]) => `(Expr.bool Β«falseΒ»)\n| `([nexpr| $e1 + $e2]) => `(Expr.add [nexpr| $e1] [nexpr| $e2])\n| `([nexpr| $e1 - $e2]) => `(Expr.sub [nexpr| $e1] [nexpr| $e2])\n| `([nexpr| $e1 * $e2]) => `(Expr.mul [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr == $e2]) => `(Expr.eq [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr < $e2]) => `(Expr.lt [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr > $e2]) => `(Expr.gt [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr <= $e2]) => `(Expr.le [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr >= $e2]) => `(Expr.ge [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:bexpr && $e2]) => `(Expr.and [bexpr| $e1] [bexpr| $e2])\n| `([bexpr| $e1:bexpr || $e2]) => `(Expr.or [bexpr| $e1] [bexpr| $e2])\n| `([bexpr| ($e)]) => `([bexpr| $e])\n| `([nexpr| ($e)]) => `([nexpr| $e])\n| `([com| skip]) => `(Com.skip)\n| `([com| let $x:ident := $e]) => `(Com.assign $(Lean.quote x.getId.toString) [nexpr| $e])\n| `([com| $x:ident := $e]) => `(Com.assign $(Lean.quote x.getId.toString) [nexpr| $e])\n| `([com| $c1; $c2]) => `(Com.seq [com| $c1] [com| $c2])\n| `([com| if $e then $c1 else $c2 fi]) => `(Com.cond [bexpr| $e] [com| $c1] [com| $c2])\n| `([com| while $e do $c od]) => `(Com.while [bexpr| $e] [com| $c])" }, { "name": "macro_rules", "content": "macro_rules\n| `([bexpr| $($t:term)]) => `($t)\n| `([nexpr| $($t:term)]) => `($t)\n| `([com| $($t:term)]) => `($t)" }, { "name": "Expr.ty", "content": "def Expr.ty : Expr β†’ Option Ty\n | Expr.num _ => Ty.num\n | Expr.bool _ => Ty.bool\n | Expr.add e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.sub e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.mul e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.eq e1 e2 => if e1.ty = e2.ty ∧ e1.ty.isSome then some .bool else none\n | Expr.lt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.gt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.le e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.ge e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.and e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none\n | Expr.or e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none\n | Expr.var _ => none " }, { "name": "Com", "content": "inductive Com\n| assign : String β†’ Expr β†’ Com\n| seq : Com β†’ Com β†’ Com\n| cond : Expr β†’ Com β†’ Com β†’ Com\n| while : Expr β†’ Com β†’ Com\n| skip : Com" }, { "name": "Expr", "content": "inductive Expr\n| num : Nat β†’ Expr\n| bool : Bool β†’ Expr\n| var : String β†’ Expr\n| add : Expr β†’ Expr β†’ Expr\n| sub : Expr β†’ Expr β†’ Expr\n| mul : Expr β†’ Expr β†’ Expr\n| eq : Expr β†’ Expr β†’ Expr\n| lt : Expr β†’ Expr β†’ Expr\n| gt : Expr β†’ Expr β†’ Expr\n| le : Expr β†’ Expr β†’ Expr\n| ge : Expr β†’ Expr β†’ Expr\n| and : Expr β†’ Expr β†’ Expr\n| or : Expr β†’ Expr β†’ Expr\nderiving Repr, DecidableEq" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "While.Ty", "content": "inductive Ty\n| num : Ty\n| bool : Ty\nderiving Repr, DecidableEq" }, { "name": "While.WellTyped", "content": "inductive WellTyped : Expr β†’ Ty β†’ Prop\n| num : WellTyped (Expr.num _) Ty.num\n| bool : WellTyped (Expr.bool _) Ty.bool\n| add : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.add e1 e2) Ty.num\n| sub : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.sub e1 e2) Ty.num\n| mul : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.mul e1 e2) Ty.num\n| eq : βˆ€ e1 e2 t, WellTyped e1 t β†’ WellTyped e2 t β†’\n WellTyped (Expr.eq e1 e2) Ty.bool\n| lt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.lt e1 e2) Ty.bool\n| gt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.gt e1 e2) Ty.bool\n| le : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.le e1 e2) Ty.bool\n| ge : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.ge e1 e2) Ty.bool\n| and : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.and e1 e2) Ty.bool\n| or : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.or e1 e2) Ty.bool" }, { "name": "While.Expr.ty", "content": "def Expr.ty : Expr β†’ Option Ty\n | Expr.num _ => Ty.num\n | Expr.bool _ => Ty.bool\n | Expr.add e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.sub e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.mul e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.eq e1 e2 => if e1.ty = e2.ty ∧ e1.ty.isSome then some .bool else none\n | Expr.lt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.gt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.le e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.ge e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.and e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none\n | Expr.or e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none\n | Expr.var _ => none" } ]
[ { "name": "While.WellTyped.ty_some", "content": "theorem WellTyped.ty_some {e ty} : WellTyped e ty β†’ e.ty = some ty" } ]
import Hoare.While.Syntax namespace While inductive Ty | num : Ty | bool : Ty deriving Repr, DecidableEq inductive WellTyped : Expr β†’ Ty β†’ Prop | num : WellTyped (Expr.num _) Ty.num | bool : WellTyped (Expr.bool _) Ty.bool | add : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.add e1 e2) Ty.num | sub : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.sub e1 e2) Ty.num | mul : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.mul e1 e2) Ty.num | eq : βˆ€ e1 e2 t, WellTyped e1 t β†’ WellTyped e2 t β†’ WellTyped (Expr.eq e1 e2) Ty.bool | lt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.lt e1 e2) Ty.bool | gt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.gt e1 e2) Ty.bool | le : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.le e1 e2) Ty.bool | ge : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.ge e1 e2) Ty.bool | and : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’ WellTyped (Expr.and e1 e2) Ty.bool | or : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’ WellTyped (Expr.or e1 e2) Ty.bool def Expr.ty : Expr β†’ Option Ty | Expr.num _ => Ty.num | Expr.bool _ => Ty.bool | Expr.add e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none | Expr.sub e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none | Expr.mul e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none | Expr.eq e1 e2 => if e1.ty = e2.ty ∧ e1.ty.isSome then some .bool else none | Expr.lt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none | Expr.gt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none | Expr.le e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none | Expr.ge e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none | Expr.and e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none | Expr.or e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none | Expr.var _ => none
theorem WellTyped.some_ty {e ty} : e.ty = some ty β†’ WellTyped e ty :=
:= by intro h induction e generalizing ty <;> simp_all [Expr.ty] case num _ => rw [← h]; exact WellTyped.num case bool _ => rw [← h]; exact WellTyped.bool case add e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h'; exact WellTyped.add e1 e2 ih_e1 ih_e2 case sub e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h'; exact WellTyped.sub e1 e2 ih_e1 ih_e2 case mul e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h'; exact WellTyped.mul e1 e2 ih_e1 ih_e2 case eq e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h' match hty : e1.ty with | some .num => have hty' := h.1.1.symm; rw [hty] at hty'; exact WellTyped.eq e1 e2 .num (ih_e1 hty') (ih_e2 hty') | some .bool => have hty' := h.1.1.symm; rw [hty] at hty'; exact WellTyped.eq e1 e2 .bool (ih_e1 hty') (ih_e2 hty') | none => rw [hty] at h; have hc := h.1.2; simp [Option.isSome] at hc case lt e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h'; exact WellTyped.lt e1 e2 ih_e1 ih_e2 case gt e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h'; exact WellTyped.gt e1 e2 ih_e1 ih_e2 case le e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h'; exact WellTyped.le e1 e2 ih_e1 ih_e2 case ge e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h'; exact WellTyped.ge e1 e2 ih_e1 ih_e2 case and e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h'; exact WellTyped.and e1 e2 ih_e1 ih_e2 case or e1 e2 ih_e1 ih_e2 => have h' := h.2.symm; subst h'; exact WellTyped.or e1 e2 ih_e1 ih_e2
3
13
false
Semantics
292
While.WellTyped.ty_some
theorem WellTyped.ty_some {e ty} : WellTyped e ty β†’ e.ty = some ty
lean-hoare
Hoare/While/Types.lean
[ "import Hoare.While.Syntax" ]
[ { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "bool", "module": "Init.Control.Basic" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Option.isSome", "module": "Init.Data.Option.Basic" } ]
[ { "name": "syntax num : nexpr", "content": "syntax num : nexpr\n\nsyntax \"if \" bexpr \" then \" com \" else \" com \" fi\" : com" }, { "name": "macro_rules", "content": "macro_rules\n| `([nexpr| $n:num]) => `(Expr.num $n)\n| `([nexpr| $x:ident]) => `(Expr.var $(Lean.quote x.getId.toString))\n| `([bexpr| true]) => `(Expr.bool Β«trueΒ»)\n| `([bexpr| false]) => `(Expr.bool Β«falseΒ»)\n| `([nexpr| $e1 + $e2]) => `(Expr.add [nexpr| $e1] [nexpr| $e2])\n| `([nexpr| $e1 - $e2]) => `(Expr.sub [nexpr| $e1] [nexpr| $e2])\n| `([nexpr| $e1 * $e2]) => `(Expr.mul [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr == $e2]) => `(Expr.eq [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr < $e2]) => `(Expr.lt [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr > $e2]) => `(Expr.gt [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr <= $e2]) => `(Expr.le [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:nexpr >= $e2]) => `(Expr.ge [nexpr| $e1] [nexpr| $e2])\n| `([bexpr| $e1:bexpr && $e2]) => `(Expr.and [bexpr| $e1] [bexpr| $e2])\n| `([bexpr| $e1:bexpr || $e2]) => `(Expr.or [bexpr| $e1] [bexpr| $e2])\n| `([bexpr| ($e)]) => `([bexpr| $e])\n| `([nexpr| ($e)]) => `([nexpr| $e])\n| `([com| skip]) => `(Com.skip)\n| `([com| let $x:ident := $e]) => `(Com.assign $(Lean.quote x.getId.toString) [nexpr| $e])\n| `([com| $x:ident := $e]) => `(Com.assign $(Lean.quote x.getId.toString) [nexpr| $e])\n| `([com| $c1; $c2]) => `(Com.seq [com| $c1] [com| $c2])\n| `([com| if $e then $c1 else $c2 fi]) => `(Com.cond [bexpr| $e] [com| $c1] [com| $c2])\n| `([com| while $e do $c od]) => `(Com.while [bexpr| $e] [com| $c])" }, { "name": "macro_rules", "content": "macro_rules\n| `([bexpr| $($t:term)]) => `($t)\n| `([nexpr| $($t:term)]) => `($t)\n| `([com| $($t:term)]) => `($t)" }, { "name": "Expr.ty", "content": "def Expr.ty : Expr β†’ Option Ty\n | Expr.num _ => Ty.num\n | Expr.bool _ => Ty.bool\n | Expr.add e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.sub e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.mul e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.eq e1 e2 => if e1.ty = e2.ty ∧ e1.ty.isSome then some .bool else none\n | Expr.lt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.gt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.le e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.ge e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.and e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none\n | Expr.or e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none\n | Expr.var _ => none " }, { "name": "Com", "content": "inductive Com\n| assign : String β†’ Expr β†’ Com\n| seq : Com β†’ Com β†’ Com\n| cond : Expr β†’ Com β†’ Com β†’ Com\n| while : Expr β†’ Com β†’ Com\n| skip : Com" }, { "name": "Expr", "content": "inductive Expr\n| num : Nat β†’ Expr\n| bool : Bool β†’ Expr\n| var : String β†’ Expr\n| add : Expr β†’ Expr β†’ Expr\n| sub : Expr β†’ Expr β†’ Expr\n| mul : Expr β†’ Expr β†’ Expr\n| eq : Expr β†’ Expr β†’ Expr\n| lt : Expr β†’ Expr β†’ Expr\n| gt : Expr β†’ Expr β†’ Expr\n| le : Expr β†’ Expr β†’ Expr\n| ge : Expr β†’ Expr β†’ Expr\n| and : Expr β†’ Expr β†’ Expr\n| or : Expr β†’ Expr β†’ Expr\nderiving Repr, DecidableEq" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "While.Ty", "content": "inductive Ty\n| num : Ty\n| bool : Ty\nderiving Repr, DecidableEq" }, { "name": "While.WellTyped", "content": "inductive WellTyped : Expr β†’ Ty β†’ Prop\n| num : WellTyped (Expr.num _) Ty.num\n| bool : WellTyped (Expr.bool _) Ty.bool\n| add : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.add e1 e2) Ty.num\n| sub : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.sub e1 e2) Ty.num\n| mul : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.mul e1 e2) Ty.num\n| eq : βˆ€ e1 e2 t, WellTyped e1 t β†’ WellTyped e2 t β†’\n WellTyped (Expr.eq e1 e2) Ty.bool\n| lt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.lt e1 e2) Ty.bool\n| gt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.gt e1 e2) Ty.bool\n| le : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.le e1 e2) Ty.bool\n| ge : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.ge e1 e2) Ty.bool\n| and : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.and e1 e2) Ty.bool\n| or : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.or e1 e2) Ty.bool" }, { "name": "While.Expr.ty", "content": "def Expr.ty : Expr β†’ Option Ty\n | Expr.num _ => Ty.num\n | Expr.bool _ => Ty.bool\n | Expr.add e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.sub e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.mul e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none\n | Expr.eq e1 e2 => if e1.ty = e2.ty ∧ e1.ty.isSome then some .bool else none\n | Expr.lt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.gt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.le e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.ge e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none\n | Expr.and e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none\n | Expr.or e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none\n | Expr.var _ => none" } ]
[]
import Hoare.While.Syntax namespace While inductive Ty | num : Ty | bool : Ty deriving Repr, DecidableEq inductive WellTyped : Expr β†’ Ty β†’ Prop | num : WellTyped (Expr.num _) Ty.num | bool : WellTyped (Expr.bool _) Ty.bool | add : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.add e1 e2) Ty.num | sub : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.sub e1 e2) Ty.num | mul : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.mul e1 e2) Ty.num | eq : βˆ€ e1 e2 t, WellTyped e1 t β†’ WellTyped e2 t β†’ WellTyped (Expr.eq e1 e2) Ty.bool | lt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.lt e1 e2) Ty.bool | gt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.gt e1 e2) Ty.bool | le : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.le e1 e2) Ty.bool | ge : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’ WellTyped (Expr.ge e1 e2) Ty.bool | and : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’ WellTyped (Expr.and e1 e2) Ty.bool | or : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’ WellTyped (Expr.or e1 e2) Ty.bool def Expr.ty : Expr β†’ Option Ty | Expr.num _ => Ty.num | Expr.bool _ => Ty.bool | Expr.add e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none | Expr.sub e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none | Expr.mul e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .num else none | Expr.eq e1 e2 => if e1.ty = e2.ty ∧ e1.ty.isSome then some .bool else none | Expr.lt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none | Expr.gt e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none | Expr.le e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none | Expr.ge e1 e2 => if e1.ty = some .num ∧ e2.ty = some .num then some .bool else none | Expr.and e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none | Expr.or e1 e2 => if e1.ty = some .bool ∧ e2.ty = some .bool then some .bool else none | Expr.var _ => none
theorem WellTyped.ty_some {e ty} : WellTyped e ty β†’ e.ty = some ty :=
:= by intro h induction h case num => rfl case bool => rfl case add _ _ h1 h2 => simp [Expr.ty, h1, h2] case sub _ _ h1 h2 => simp [Expr.ty, h1, h2] case mul _ _ h1 h2 => simp [Expr.ty, h1, h2] case eq e1 _ _ h1 h2 => simp [Expr.ty, h1, h2] case lt _ _ h1 h2 => simp [Expr.ty, h1, h2] case gt _ _ h1 h2 => simp [Expr.ty, h1, h2] case le _ _ h1 h2 => simp [Expr.ty, h1, h2] case ge _ _ h1 h2 => simp [Expr.ty, h1, h2] case and _ _ h1 h2 => simp [Expr.ty, h1, h2] case or _ _ h1 h2 => simp [Expr.ty, h1, h2]
4
13
false
Semantics
293
While.WellTyped.not_eq_not_eq_ty
theorem WellTyped.not_eq_not_eq_ty {e1 e2 : Expr} {t1 t2 : Ty} : WellTyped e1 t1 β†’ WellTyped e2 t2 β†’ t1 β‰  t2 β†’ βˆ€ t, Β¬ (WellTyped (Expr.eq e1 e2) t)
lean-hoare
Hoare/While/Types.lean
[ "import Hoare.While.Syntax" ]
[ { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "bool", "module": "Init.Control.Basic" } ]
[ { "name": "Expr", "content": "inductive Expr\n| num : Nat β†’ Expr\n| bool : Bool β†’ Expr\n| var : String β†’ Expr\n| add : Expr β†’ Expr β†’ Expr\n| sub : Expr β†’ Expr β†’ Expr\n| mul : Expr β†’ Expr β†’ Expr\n| eq : Expr β†’ Expr β†’ Expr\n| lt : Expr β†’ Expr β†’ Expr\n| gt : Expr β†’ Expr β†’ Expr\n| le : Expr β†’ Expr β†’ Expr\n| ge : Expr β†’ Expr β†’ Expr\n| and : Expr β†’ Expr β†’ Expr\n| or : Expr β†’ Expr β†’ Expr\nderiving Repr, DecidableEq" }, { "name": "WellTyped", "content": "inductive WellTyped : Expr β†’ Ty β†’ Prop\n| num : WellTyped (Expr.num _) Ty.num\n| bool : WellTyped (Expr.bool _) Ty.bool\n| add : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.add e1 e2) Ty.num\n| sub : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.sub e1 e2) Ty.num\n| mul : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.mul e1 e2) Ty.num\n| eq : βˆ€ e1 e2 t, WellTyped e1 t β†’ WellTyped e2 t β†’\n WellTyped (Expr.eq e1 e2) Ty.bool\n| lt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.lt e1 e2) Ty.bool\n| gt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.gt e1 e2) Ty.bool\n| le : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.le e1 e2) Ty.bool\n| ge : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.ge e1 e2) Ty.bool\n| and : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.and e1 e2) Ty.bool\n| or : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.or e1 e2) Ty.bool" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "While.Ty", "content": "inductive Ty\n| num : Ty\n| bool : Ty\nderiving Repr, DecidableEq" }, { "name": "While.WellTyped", "content": "inductive WellTyped : Expr β†’ Ty β†’ Prop\n| num : WellTyped (Expr.num _) Ty.num\n| bool : WellTyped (Expr.bool _) Ty.bool\n| add : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.add e1 e2) Ty.num\n| sub : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.sub e1 e2) Ty.num\n| mul : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.mul e1 e2) Ty.num\n| eq : βˆ€ e1 e2 t, WellTyped e1 t β†’ WellTyped e2 t β†’\n WellTyped (Expr.eq e1 e2) Ty.bool\n| lt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.lt e1 e2) Ty.bool\n| gt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.gt e1 e2) Ty.bool\n| le : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.le e1 e2) Ty.bool\n| ge : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.ge e1 e2) Ty.bool\n| and : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.and e1 e2) Ty.bool\n| or : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.or e1 e2) Ty.bool" } ]
[ { "name": "While.WellTyped.unique", "content": "theorem WellTyped.unique : βˆ€ {e t1 t2}, WellTyped e t1 β†’ WellTyped e t2 β†’ t1 = t2" } ]
import Hoare.While.Syntax namespace While inductive Ty | num : Ty | bool : Ty deriving Repr, DecidableEq
theorem WellTyped.not_eq_not_eq_ty {e1 e2 : Expr} {t1 t2 : Ty} : WellTyped e1 t1 β†’ WellTyped e2 t2 β†’ t1 β‰  t2 β†’ βˆ€ t, Β¬ (WellTyped (Expr.eq e1 e2) t) :=
:= by intro h1 h2 h3 t h4 cases h4 Β· case eq t h1' h2' => have ht1 : t1 = t := WellTyped.unique h1 h1' have ht2 : t2 = t := WellTyped.unique h2 h2' rw [ht1, ht2] at h3 contradiction
2
6
false
Semantics
294
While.WellTyped.not_welltyped_not_eq_ty
theorem WellTyped.not_welltyped_not_eq_ty {e1 e2 : Expr} {t : Ty} : WellTyped e1 t β†’ Β¬ WellTyped e2 t β†’ βˆ€ t', Β¬ (WellTyped (Expr.eq e1 e2) t')
lean-hoare
Hoare/While/Types.lean
[ "import Hoare.While.Syntax" ]
[ { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "bool", "module": "Init.Control.Basic" } ]
[ { "name": "Expr", "content": "inductive Expr\n| num : Nat β†’ Expr\n| bool : Bool β†’ Expr\n| var : String β†’ Expr\n| add : Expr β†’ Expr β†’ Expr\n| sub : Expr β†’ Expr β†’ Expr\n| mul : Expr β†’ Expr β†’ Expr\n| eq : Expr β†’ Expr β†’ Expr\n| lt : Expr β†’ Expr β†’ Expr\n| gt : Expr β†’ Expr β†’ Expr\n| le : Expr β†’ Expr β†’ Expr\n| ge : Expr β†’ Expr β†’ Expr\n| and : Expr β†’ Expr β†’ Expr\n| or : Expr β†’ Expr β†’ Expr\nderiving Repr, DecidableEq" }, { "name": "WellTyped", "content": "inductive WellTyped : Expr β†’ Ty β†’ Prop\n| num : WellTyped (Expr.num _) Ty.num\n| bool : WellTyped (Expr.bool _) Ty.bool\n| add : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.add e1 e2) Ty.num\n| sub : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.sub e1 e2) Ty.num\n| mul : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.mul e1 e2) Ty.num\n| eq : βˆ€ e1 e2 t, WellTyped e1 t β†’ WellTyped e2 t β†’\n WellTyped (Expr.eq e1 e2) Ty.bool\n| lt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.lt e1 e2) Ty.bool\n| gt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.gt e1 e2) Ty.bool\n| le : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.le e1 e2) Ty.bool\n| ge : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.ge e1 e2) Ty.bool\n| and : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.and e1 e2) Ty.bool\n| or : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.or e1 e2) Ty.bool" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[ { "name": "While.Ty", "content": "inductive Ty\n| num : Ty\n| bool : Ty\nderiving Repr, DecidableEq" }, { "name": "While.WellTyped", "content": "inductive WellTyped : Expr β†’ Ty β†’ Prop\n| num : WellTyped (Expr.num _) Ty.num\n| bool : WellTyped (Expr.bool _) Ty.bool\n| add : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.add e1 e2) Ty.num\n| sub : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.sub e1 e2) Ty.num\n| mul : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.mul e1 e2) Ty.num\n| eq : βˆ€ e1 e2 t, WellTyped e1 t β†’ WellTyped e2 t β†’\n WellTyped (Expr.eq e1 e2) Ty.bool\n| lt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.lt e1 e2) Ty.bool\n| gt : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.gt e1 e2) Ty.bool\n| le : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.le e1 e2) Ty.bool\n| ge : βˆ€ e1 e2, WellTyped e1 Ty.num β†’ WellTyped e2 Ty.num β†’\n WellTyped (Expr.ge e1 e2) Ty.bool\n| and : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.and e1 e2) Ty.bool\n| or : βˆ€ e1 e2, WellTyped e1 Ty.bool β†’ WellTyped e2 Ty.bool β†’\n WellTyped (Expr.or e1 e2) Ty.bool" } ]
[ { "name": "While.WellTyped.unique", "content": "theorem WellTyped.unique : βˆ€ {e t1 t2}, WellTyped e t1 β†’ WellTyped e t2 β†’ t1 = t2" } ]
import Hoare.While.Syntax namespace While inductive Ty | num : Ty | bool : Ty deriving Repr, DecidableEq
theorem WellTyped.not_welltyped_not_eq_ty {e1 e2 : Expr} {t : Ty} : WellTyped e1 t β†’ Β¬ WellTyped e2 t β†’ βˆ€ t', Β¬ (WellTyped (Expr.eq e1 e2) t') :=
:= by intro h1 h2 t' h3 cases h3 Β· case eq t' h1' h2' => have ht : t = t' := WellTyped.unique h1 h1' apply h2 rw [ht] exact h2'
2
6
false
Semantics
295
processOneElem_spec
omit [Fintype S] in lemma processOneElem_spec {st : worklist.St A S} (s : State) (sa : S) (k : β„•) : βˆ€ a sa', (f sa)[k]? = some (a, sa') β†’ processOneElem_mot inits final f s sa k st β†’ processOneElem_mot inits final f s sa (k+1) (processOneElem A S final s st (a, sa'))
lean-mlir
Blase/Blase/AutoStructs/Worklist.lean
[ "import Blase.Blase.AutoStructs.Basic", "import Blase.Blase.AutoStructs.ForLean", "import Blase.AutoStructs.Basic" ]
[ { "name": "Nat", "module": "Init.Prelude" }, { "name": "BEq", "module": "Init.Prelude" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "FinEnum", "module": "Mathlib.Data.FinEnum" }, { "name": "Hashable", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Std.HashMap", "module": "Std.Data.HashMap.Basic" }, { "name": "Std.HashSet", "module": "Std.Data.HashSet.Basic" }, { "name": "Array", "module": "Init.Prelude" }, { "name": "List.map", "module": "Init.Prelude" }, { "name": "SetRel", "module": "Mathlib.Data.Rel" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "NFA", "module": "Mathlib.Computability.NFA" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Finset", "module": "Mathlib.Data.Finset.Defs" }, { "name": "Option", "module": "Init.Prelude" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "Prod.mk", "module": "Init.Prelude" }, { "name": "Finset.range", "module": "Mathlib.Data.Finset.Range" }, { "name": "Fintype", "module": "Mathlib.Data.Fintype.Defs" }, { "name": "SetRel.inv", "module": "Mathlib.Data.Rel" }, { "name": "LawfulBEq", "module": "Init.Core" }, { "name": "List.next", "module": "Mathlib.Data.List.Cycle" }, { "name": "LawfulHashable", "module": "Init.Data.LawfulHashable" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "List.insert", "module": "Init.Data.List.Basic" } ]
[ { "name": "RawCNFA.statesFinset", "content": "instance RawCNFA.statesFinset (m : RawCNFA A) : Fintype m.states := (Finset.range m.stateMax).fintypeCoeSort" }, { "name": "State", "content": "abbrev State := Nat" }, { "name": "RawCNFA.WF", "content": "structure RawCNFA.WF (m : RawCNFA A) where\n initials_lt : βˆ€ {s}, s ∈ m.initials β†’ s ∈ m.states\n finals_lt : βˆ€ {s}, s ∈ m.finals β†’ s ∈ m.states\n trans_src_lt : βˆ€ s_a ∈ m.trans, s_a.1 ∈ m.states\n trans_tgt_lt : s' ∈ m.tr s a β†’ s' ∈ m.states" }, { "name": "RawCNFA.tr", "content": "@[inline]\ndef RawCNFA.tr (m : RawCNFA A) s a := m.trans.getD (s, a) βˆ…" }, { "name": "RawCNFA.states", "content": "def RawCNFA.states (m : RawCNFA A) : Finset State := Finset.range m.stateMax" }, { "name": "RawCNFA.addFinal", "content": "def RawCNFA.addFinal (m : RawCNFA A) (s : State) : RawCNFA A :=\n { m with finals := m.finals.insert s }" }, { "name": "RawCNFA.newState", "content": "def RawCNFA.newState (m : RawCNFA A) : State Γ— RawCNFA A :=\n let old := m.stateMax\n let m := { m with stateMax := old + 1 }\n (old, m)" }, { "name": "RawCNFA.addTrans", "content": "def RawCNFA.addTrans (m : RawCNFA A) (a : A) (s s' : State) : RawCNFA A :=\n let ns := m.trans.getD (s, a) βˆ…\n let ns := ns.insert s'\n { m with trans := m.trans.insert (s, a) ns }" } ]
[ { "name": "Std.HashMap.getElem?_insert", "module": "Std.Data.HashMap.Lemmas" }, { "name": "getElem?_eq_none_iff", "module": "Init.GetElem" }, { "name": "Set.mem_setOf_eq", "module": "Mathlib.Data.Set.Operations" }, { "name": "true_and", "module": "Init.SimpLemmas" }, { "name": "Array.mem_of_getElem?", "module": "Init.Data.Array.Lemmas" }, { "name": "Prod.mk.eta", "module": "Mathlib.Data.Prod.Basic" }, { "name": "Std.HashSet.mem_insert", "module": "Std.Data.HashSet.Lemmas" }, { "name": "beq_iff_eq", "module": "Init.Core" }, { "name": "ge_iff_le", "module": "Init.Core" }, { "name": "not_and", "module": "Init.SimpLemmas" }, { "name": "not_exists", "module": "Init.PropLemmas" }, { "name": "or_true", "module": "Init.SimpLemmas" }, { "name": "true_or", "module": "Init.SimpLemmas" } ]
[ { "name": "Std.HashMap.get?_none_not_mem", "content": "@[aesop 50% unsafe]\ntheorem Std.HashMap.get?_none_not_mem [BEq K] [LawfulBEq K] [Hashable K] [LawfulHashable K] {m : Std.HashMap K V} {k : K} : m.get? k = none β†’ k βˆ‰ m" }, { "name": "Std.HashMap.mem_of_getElem?", "content": "@[aesop 50% unsafe]\ntheorem Std.HashMap.mem_of_getElem? [BEq K] [LawfulBEq K] [Hashable K] [LawfulHashable K] {m : Std.HashMap K V} {k : K} :\n m[k]? = some v β†’ k ∈ m" }, { "name": "Std.HashMap.mem_iff_getElem?", "content": "theorem Std.HashMap.mem_iff_getElem? [BEq K] [LawfulBEq K] [Hashable K] [LawfulHashable K] [Inhabited V] {m : Std.HashMap K V} {k : K} :\n k ∈ m ↔ βˆƒ v, m[k]? = some v" }, { "name": "addTrans_tr_eq", "content": "@[grind =, simp]\nlemma addTrans_tr_eq (m : RawCNFA A) [LawfulBEq A] (a : A) (s₁ sβ‚‚ : State) :\n (m.addTrans a s₁ sβ‚‚).tr s₁ a = (m.tr s₁ a).insert sβ‚‚" }, { "name": "@[grind =] -- TODO: should I?", "content": "@[grind =] -- TODO: should I?\nlemma addTrans_tr (m : RawCNFA A) [LawfulBEq A] {a b : A} {s₁ s₁' sβ‚‚ : State} :\n (m.addTrans a s₁ sβ‚‚).tr s₁' b = if s₁ = s₁' ∧ a = b then (m.tr s₁ a).insert sβ‚‚ else m.tr s₁' b" }, { "name": "RawCNFA.WF.trans_src_lt''", "content": "@[grind ., simp, aesop 50% unsafe]\nlemma RawCNFA.WF.trans_src_lt'' [LawfulBEq A] {m : RawCNFA A} (hwf : m.WF) :\n βˆ€ {s a s'}, s' ∈ m.tr s a β†’ s ∈ m.states" }, { "name": "RawCNFA.WF.trans_src_lt'", "content": "@[grind ., simp, aesop 50% unsafe]\nlemma RawCNFA.WF.trans_src_lt' {m : RawCNFA A} (hwf : m.WF) :\n βˆ€ {s a}, (s, a) ∈ m.trans β†’ s ∈ m.states" }, { "name": "Std.HashMap.getElem?_none_not_mem", "content": "@[aesop 50% unsafe]\ntheorem Std.HashMap.getElem?_none_not_mem [BEq K] [LawfulBEq K] [Hashable K] [LawfulHashable K] {m : Std.HashMap K V} {k : K} :\n m[k]? = none β†’ k βˆ‰ m" } ]
[ { "name": "nfa", "content": "def nfa : NFA A S where\n start := { sa | sa ∈ inits }\n accept := { sa | final sa }\n step sa a := { sa' | (a, sa') ∈ f sa }" }, { "name": "worklist.St", "content": "structure worklist.St where\n m : RawCNFA A\n map : Std.HashMap S State := βˆ…\n worklist : Array S := βˆ…\n worklist_nodup : worklist.toList.Nodup\n worklist_incl : βˆ€ sa ∈ worklist, sa ∈ map" }, { "name": "worklist.St.addOrCreateState", "content": "def worklist.St.addOrCreateState (st : worklist.St A S) (final? : Bool) (sa : S) : State Γ— worklist.St A S :=\n match heq : st.map[sa]? with\n | some s => (s, st)\n | none =>\n let (s, m) := st.m.newState\n let m := if final? then m.addFinal s else m\n let map := st.map.insert sa s\n let worklist := st.worklist.push sa\n have worklist_nodup : worklist.toList.Nodup := by admit /- proof elided -/" }, { "name": "processOneElem", "content": "def processOneElem (final : S β†’ Bool) (s : State) (st : worklist.St A S) : A Γ— S β†’ worklist.St A S :=\n fun (a', sa') =>\n let (s', st') := st.addOrCreateState _ _ (final sa') sa'\n let m := st'.m.addTrans a' s s'\n { st' with m }" }, { "name": "worklist.St.visited", "content": "def worklist.St.visited (st : worklist.St A S) : Set S := { s : S | s ∈ st.map ∧ s βˆ‰ st.worklist }" }, { "name": "StInv", "content": "structure StInv (m : RawCNFA A) (map : Std.HashMap S State) where\n wf : m.WF\n map_states : βˆ€ (sa : S) s, map[sa]? = some s β†’ s ∈ m.states\n map_surj : βˆ€ s : m.states, βˆƒ (sa : S), map[sa]? = some s.val\n map_inj : βˆ€ {s} {sa sa' : S}, map[sa]? = some s β†’ map[sa']? = some s β†’ sa = sa'" }, { "name": "worklist.St.rel", "content": "def worklist.St.rel (st : worklist.St A S) : SetRel State S := {(s, sa) | st.map[sa]? = some s }" }, { "name": "worklist.St.D", "content": "def worklist.St.D (st : worklist.St A S) : Set S := st.visited" }, { "name": "worklist.St.sim", "content": "abbrev worklist.St.sim {st : worklist.St A S} (T : Set (S Γ— A Γ— S)) :=\n st.m.Simul (nfa inits final f) st.rel st.D T" }, { "name": "processOneElem_mot", "content": "def processOneElem_mot (s : State) (sa : S) (n : β„•) (st : worklist.St A S) : Prop :=\n st.map[sa]? = some s ∧\n sa ∈ st.visited ∧\n StInv A S st.m st.map ∧\n st.sim inits final f {(sa1, a, sa') | sa1 = sa ∧ βˆƒ k β‰₯ n, (f sa)[k]? = some (a, sa') }" }, { "name": "processOneElem_inv", "content": "def processOneElem_inv {st : worklist.St A S} (s : State) (sa : S) (k : β„•) :\n βˆ€ a sa', (f sa)[k]? = some (a, sa') β†’\n processOneElem_mot inits final f s sa k st β†’\n let st' := processOneElem A S final s st (a, sa')\n StInv A S st'.m st'.map :=" } ]
[ { "name": "addOrCreate_preserves_map", "content": "omit [Fintype S] [LawfulBEq A] in\nlemma addOrCreate_preserves_map (st : worklist.St A S) (final? : Bool) (sa sa' : S) :\n let (_, st') := st.addOrCreateState _ _ final? sa'\n st.map[sa]? = some s β†’\n st'.map[sa]? = some s" }, { "name": "processOneElem_preserves_map", "content": "omit [Fintype S] [LawfulBEq A] in\nlemma processOneElem_preserves_map (st : worklist.St A S) (final : S β†’ Bool) (a : A) (sa sa' : S) (s s' : State) :\n let st' := processOneElem _ _ final s st (a, sa')\n st.map[sa]? = some s' β†’\n st'.map[sa]? = some s'" }, { "name": "addOrCreateElem_visited", "content": "omit [LawfulBEq A] [Fintype S] [DecidableEq S] in\nlemma addOrCreateElem_visited final? (st : worklist.St A S) sa :\n st.addOrCreateState _ _ final? sa |>.2.visited = st.visited" }, { "name": "processOneElem_visited", "content": "omit [LawfulBEq A] [Fintype S] [DecidableEq S] in\nlemma processOneElem_visited (st : worklist.St A S) :\n let st' := processOneElem _ _ final s st (a, sa')\n st'.visited = st.visited" }, { "name": "processOneElem_map", "content": "omit [LawfulBEq A] [Fintype S] in\nlemma processOneElem_map (st : worklist.St A S) (final : S β†’ Bool) (a : A) (sa sa' : S) (s : State) :\n (processOneElem A S final s st (a, sa)).map[sa']? =\n match st.map[sa']? with\n | some s => some s\n | none => if sa = sa' then some st.m.stateMax else none" }, { "name": "processOneElem_initials", "content": "omit [LawfulBEq A] [Fintype S] [DecidableEq S] in\n@[simp]\nlemma processOneElem_initials (st : worklist.St A S) (final : S β†’ Bool) (a : A) (sa : S) (s : State) :\n (processOneElem A S final s st (a, sa)).m.initials = st.m.initials" }, { "name": "processOneElem_finals", "content": "omit [LawfulBEq A] [Fintype S] [DecidableEq S] in\nlemma processOneElem_finals (st : worklist.St A S) (final : S β†’ Bool) (a : A) (sa : S) (s : State) :\n (processOneElem A S final s st (a, sa)).m.finals =\n if sa βˆ‰ st.map ∧ final sa then st.m.finals.insert st.m.stateMax else st.m.finals" }, { "name": "processOneElem_tr", "content": "omit [Fintype S] [DecidableEq S] in\nlemma processOneElem_tr (st : worklist.St A S) (final : S β†’ Bool) (a b : A) (sa : S) (s s' : State) :\n if a = b ∧ s = s' then\n βˆƒ ssa, (processOneElem A S final s st (a, sa)).map[sa]? = some ssa ∧\n (processOneElem A S final s st (a, sa)).m.tr s' b =\n (st.m.tr s a |>.insert ssa)\n else\n (processOneElem A S final s st (a, sa)).m.tr s' b = st.m.tr s' b" }, { "name": "processOneElem_rel", "content": "omit [LawfulBEq A] [Fintype S] in\nlemma processOneElem_rel {s₁ sβ‚‚ : State} :\n sβ‚‚ ~[(processOneElem A S final s₁ st (a, sa)).rel] sa' ↔\n (sβ‚‚ ~[st.rel] sa' ∨ (sβ‚‚ = st.m.stateMax ∧ sa' = sa ∧ st.map[sa']? = none))" }, { "name": "rel_in_states", "content": "omit [LawfulBEq A] [Fintype S] [LawfulBEq S] [DecidableEq S] in\nlemma rel_in_states {st : worklist.St A S} (hinv : StInv A S st.m st.map) :\n s ~[st.rel] sa β†’ s ∈ st.m.states" }, { "name": "processOneElem_rel_preserve", "content": "omit [LawfulBEq A] [Fintype S] in\nlemma processOneElem_rel_preserve :\n sβ‚‚ ~[st.rel] sa' β†’\n sβ‚‚ ~[(processOneElem A S final s₁ st (a, sa)).rel] sa'" }, { "name": "processOneElem_rel_preserve_olds", "content": "omit [LawfulBEq A] [Fintype S] in\nlemma processOneElem_rel_preserve_olds :\n sβ‚‚ ~[(processOneElem A S final s₁ st (a, sa)).rel] sa' β†’\n sβ‚‚ ∈ st.m.states β†’ sβ‚‚ ~[st.rel] sa'" } ]
import Blase.AutoStructs.Basic open SetRel section nfa variable {A : Type} [BEq A] [LawfulBEq A] [Hashable A] [DecidableEq A] [FinEnum A] variable {S : Type} [Fintype S] [BEq S] [LawfulBEq S] [Hashable S] [DecidableEq S] variable (inits : Array S) (final : S β†’ Bool) (f : S β†’ Array (A Γ— S)) def nfa : NFA A S where start := { sa | sa ∈ inits } accept := { sa | final sa } step sa a := { sa' | (a, sa') ∈ f sa } end nfa section nfa' variable {S : Type} [Fintype S] [BEq S] [LawfulBEq S] [Hashable S] [DecidableEq S] variable (inits : Array S) (final : S β†’ Bool) (f : S β†’ Array (BitVec n Γ— S)) end nfa' section worklist variable (A : Type) [BEq A] [LawfulBEq A] [Hashable A] [DecidableEq A] [FinEnum A] variable (S : Type) [Fintype S] [BEq S] [LawfulBEq S] [Hashable S] [DecidableEq S] structure worklist.St where m : RawCNFA A map : Std.HashMap S State := βˆ… worklist : Array S := βˆ… worklist_nodup : worklist.toList.Nodup worklist_incl : βˆ€ sa ∈ worklist, sa ∈ map open List in def worklist.St.addOrCreateState (st : worklist.St A S) (final? : Bool) (sa : S) : State Γ— worklist.St A S := match heq : st.map[sa]? with | some s => (s, st) | none => let (s, m) := st.m.newState let m := if final? then m.addFinal s else m let map := st.map.insert sa s let worklist := st.worklist.push sa have worklist_nodup : worklist.toList.Nodup := by admit /- proof elided -/ def processOneElem (final : S β†’ Bool) (s : State) (st : worklist.St A S) : A Γ— S β†’ worklist.St A S := fun (a', sa') => let (s', st') := st.addOrCreateState _ _ (final sa') sa' let m := st'.m.addTrans a' s s' { st' with m } open List in have hgrow : βˆƒ sas, st2.map.keys ~ (sas ++ st1.map.keys) ∧ st2.worklist.toList = st1.worklist.toList ++ sas := by rcases a with ⟨al⟩ unfold st2 generalize hst1 : st1 = x; clear hst1; revert x induction al with | nil => simp | cons asa al ih => simp; simp at ih; intros st let wl' := processOneElem A S final s st asa rcases ih wl' with ⟨sas', h1', h2'⟩; clear ih rcases processOneElem_grow _ _ st final asa.1 asa.2 s with ⟨sas, h1, h2⟩ use (sas ++ sas') constructor { simp [wl'] at h1'; apply list_perm_trick; exact h1'; exact h1 } { simp [wl', h2] at h2'; aesop } have hincl : βˆ€ k, k ∈ st1.map β†’ k ∈ st2.map := by intros k; rcases hgrow with ⟨sas, hkeys, -⟩; have := @(List.perm_subset_iff_right hkeys st1.map.keys).mpr (by aesop) k; aesop have : st1.meas < st0.meas := by rcases heq' : sa? with ⟨⟩ | ⟨sa⟩ { simp_all } apply Finset.card_lt_card simp [Finset.ssubset_iff, Finset.subset_iff] use sa simp [sa?] at heq' constructor { constructor { apply Array.mem_of_back? at heq'; apply st0.worklist_incl; assumption } { apply Array.not_elem_back_pop at heq' <;> simp_all +zetaDelta [Array.pop] } } constructor { right; apply Array.mem_of_back? at heq'; assumption } rintro sa hh; rcases hh with hnin | hin { simp +zetaDelta [hnin] } right exact Array.mem_of_mem_pop st0.worklist sa hin have : st2.meas ≀ st1.meas := by apply Finset.card_le_card simp +zetaDelta [Finset.subset_iff] intros sa' h rcases h with hnin | hin { left; simp [st1] at hincl; intros hc; apply hnin; apply hincl; assumption } by_cases hnew : sa' ∈ st0.map all_goals try (left; trivial) right simp [st1] at hgrow rcases hgrow with ⟨sas, hkeys2, hwl2⟩ have hnin : sa'βˆ‰ sas := by intros hc have hdisj : st0.map.keys.Disjoint sas := by have : (sas ++ st0.map.keys).Nodup := by apply List.Perm.nodup assumption apply st2.map.keys_nodup simp [List.nodup_append_comm, List.disjoint_of_nodup_append, this] apply hdisj { simp_all [Std.HashMap.mem_keys]; apply hnew } { apply hc } rcases hin with ⟨hin⟩; simp_all +zetaDelta have : st2.meas < st0.meas := by omega go st2 else st0.m -- never happens | none => st0.m -- never happens termination_by st0.meas def worklist.St.visited (st : worklist.St A S) : Set S := { s : S | s ∈ st.map ∧ s βˆ‰ st.worklist } structure StInv (m : RawCNFA A) (map : Std.HashMap S State) where wf : m.WF map_states : βˆ€ (sa : S) s, map[sa]? = some s β†’ s ∈ m.states map_surj : βˆ€ s : m.states, βˆƒ (sa : S), map[sa]? = some s.val map_inj : βˆ€ {s} {sa sa' : S}, map[sa]? = some s β†’ map[sa']? = some s β†’ sa = sa' end worklist section worklist_correct variable {A : Type} [BEq A] [LawfulBEq A] [Hashable A] [DecidableEq A] [FinEnum A] variable {S : Type} [Fintype S] [BEq S] [LawfulBEq S] [Hashable S] [DecidableEq S] variable (inits : Array S) (final : S β†’ Bool) (f : S β†’ Array (A Γ— S)) def worklist.St.rel (st : worklist.St A S) : SetRel State S := {(s, sa) | st.map[sa]? = some s } def worklist.St.D (st : worklist.St A S) : Set S := st.visited abbrev worklist.St.sim {st : worklist.St A S} (T : Set (S Γ— A Γ— S)) := st.m.Simul (nfa inits final f) st.rel st.D T def processOneElem_mot (s : State) (sa : S) (n : β„•) (st : worklist.St A S) : Prop := st.map[sa]? = some s ∧ sa ∈ st.visited ∧ StInv A S st.m st.map ∧ st.sim inits final f {(sa1, a, sa') | sa1 = sa ∧ βˆƒ k β‰₯ n, (f sa)[k]? = some (a, sa') } def processOneElem_inv {st : worklist.St A S} (s : State) (sa : S) (k : β„•) : βˆ€ a sa', (f sa)[k]? = some (a, sa') β†’ processOneElem_mot inits final f s sa k st β†’ let st' := processOneElem A S final s st (a, sa') StInv A S st'.m st'.map :=
omit [Fintype S] in lemma processOneElem_spec {st : worklist.St A S} (s : State) (sa : S) (k : β„•) : βˆ€ a sa', (f sa)[k]? = some (a, sa') β†’ processOneElem_mot inits final f s sa k st β†’ processOneElem_mot inits final f s sa (k+1) (processOneElem A S final s st (a, sa')) :=
:= by intro a sa' hf ⟨hmap, hvisited, inv, hsim⟩ have hmem : βˆ€ s (sa : S), st.map[sa]? = some s β†’ s ∈ st.m.states := by intros; apply inv.map_states; assumption have hwf : st.m.WF := by apply inv.wf have inv' := processOneElem_inv inits final f s sa k a sa' hf ⟨hmap, hvisited, inv, hsim⟩ unfold processOneElem_mot constructor (rw [processOneElem_preserves_map]; assumption) constructor (rw [processOneElem_visited]; exact hvisited) use inv'; constructor { rw [processOneElem_finals] rintro s' q hR have hs' : s ∈ st.m.states := by apply hmem <;> assumption rw [processOneElem_rel] at hR rcases hR with hR | ⟨rfl, rfl, heq⟩ Β· have heq := rel_in_states inv hR split_ifs with hcond Β· have hneq : st.m.stateMax β‰  s' := by rintro rfl; simp [RawCNFA.states] at heq simp [hneq] apply hsim.accept; assumption Β· apply hsim.accept; assumption Β· split_ifs with h Β· rcases h with ⟨_, hfin⟩ simp [nfa, hfin] Β· simp [nfa] suffices hnin : q βˆ‰ st.map by push_neg at h; specialize h hnin; simp_all rintro hc; apply hwf.finals_lt at hc; simp at hc exact Std.HashMap.getElem?_none_not_mem heq } { rintro s₁ hs₁; rw [processOneElem_initials] at hs₁ obtain ⟨q, hq, hR⟩ := hsim.initial₁ hs₁ use q, hq, processOneElem_rel_preserve final hR } { intros q hq; obtain ⟨s, hs, hR⟩ := hsim.initialβ‚‚ hq simp only [processOneElem_initials] use s, hs, (by exact processOneElem_rel_preserve final hR) } { rintro s₁ sβ‚‚ b q₁ hR htr have h := processOneElem_tr st final a b sa' s s₁ split_ifs at h with hcond on_goal 2 => { rw [h] at htr apply processOneElem_rel_preserve_olds at hR specialize hR (RawCNFA.WF.trans_src_lt'' hwf htr) obtain ⟨qβ‚‚, hst, hrel⟩ := hsim.trans_match₁ hR htr use qβ‚‚; simp only [hst, true_and] exact processOneElem_rel_preserve final hrel } rcases hcond with ⟨rfl, rfl⟩ rcases h with ⟨sβ‚™, hmap', htr'⟩ rw [htr'] at htr; clear htr' simp only [Std.HashSet.mem_insert, beq_iff_eq] at htr rcases htr with rfl | htr on_goal 2 => have hold := RawCNFA.WF.trans_src_lt'' hwf htr obtain ⟨qβ‚‚, hst, hrel⟩ := hsim.trans_match₁ (by apply processOneElem_rel_preserve_olds final hR hold) htr use qβ‚‚, hst, processOneElem_rel_preserve final hrel use sa'; constructor Β· suffices heq : q₁ = sa by subst heq; apply Array.mem_of_getElem? hf apply processOneElem_preserves_map at hmap unfold worklist.St.rel at hR apply inv'.map_inj hR hmap Β· exact hmap' } { rintro s₁ b q₁ qβ‚‚ hR hs hD hnT simp only [ge_iff_le, Prod.mk.eta, Set.mem_setOf_eq, not_and, not_exists] at hnT have h := processOneElem_tr st final a b sa' s s₁ split_ifs at h with hcond on_goal 2 => have hR' : s₁ ~[st.rel] q₁ := by rw [processOneElem_rel] at hR; rcases hR with hR' | ⟨_, _, hnone⟩; exact hR' unfold worklist.St.D at hD; rw [processOneElem_visited] at hD rcases hD with ⟨hnin, -⟩ apply Std.HashMap.getElem?_none_not_mem at hnone contradiction obtain ⟨sβ‚‚, hs', hR⟩ := hsim.trans_matchβ‚‚ hR' hs (by simp_all [worklist.St.D, processOneElem_visited]) (by simp; rintro rfl i hi hc by_cases heq: k = i Β· subst heq; apply hcond; constructor Β· simp [hc] at hf; simp [hf] Β· rw [hR'] at hmap; simp at hmap; exact hmap.symm Β· apply hnT rfl _ (by omega) hc) use sβ‚‚; simp only [h, hs', true_and] apply processOneElem_rel_preserve; assumption rcases hcond with ⟨rfl, rfl⟩ rcases h with ⟨sβ‚™, hmap', htr'⟩ obtain rfl : sa = q₁ := by apply processOneElem_preserves_map at hmap apply inv'.map_inj hmap hR simp only [htr', Std.HashSet.mem_insert, beq_iff_eq] by_cases heq : sa' = qβ‚‚ Β· subst heq; use sβ‚™; simp only [true_or, true_and]; exact hmap' Β· have hold := hmem _ _ hmap apply processOneElem_rel_preserve_olds at hR obtain ⟨sβ‚‚, hs', hR⟩ := hsim.trans_matchβ‚‚ (hR hold) hs (by simp_all [worklist.St.D, processOneElem_visited]) (by simp; rintro i hi hc have _ : i β‰  k := by rintro rfl; simp_all apply hnT rfl i (by omega) hc) use sβ‚‚; simp only [hs', or_true, true_and] apply processOneElem_rel_preserve; assumption }
5
79
false
Compiler
296
formula_language_case_atom
lemma formula_language_case_atom : let Ο† := Formula.atom rel t1 t2 Ο†.language = Ξ» (bvs : BitVecs Ο†.arity) => Ο†.sat (fun k => bvs.bvs.get k)
lean-mlir
Blase/Blase/AutoStructs/Defs.lean
[ "import Blase.SingleWidth.Defs", "import Blase.Blase.AutoStructs.ForMathlib", "import Blase.AutoStructs.ForMathlib" ]
[ { "name": "Fin", "module": "Init.Prelude" }, { "name": "Fin.last", "module": "Init.Data.Fin.Basic" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Fin.castLE", "module": "Init.Data.Fin.Basic" }, { "name": "BitVec", "module": "Init.Prelude" }, { "name": "BitVec.ofNat", "module": "Init.Prelude" }, { "name": "BitVec.zero", "module": "Init.Data.BitVec.Basic" }, { "name": "List", "module": "Init.Prelude" }, { "name": "List.Vector", "module": "Mathlib.Data.Vector.Defs" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Fintype", "module": "Mathlib.Data.Fintype.Defs" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "BitVec.iunfoldr", "module": "Init.Data.BitVec.Folds" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "Vector.ofFn", "module": "Init.Data.Vector.Basic" }, { "name": "impl", "module": "Mathlib.Deprecated.MLList.BestFirst" }, { "name": "FinEnum", "module": "Mathlib.Data.FinEnum" }, { "name": "FinEnum.card", "module": "Mathlib.Data.FinEnum" }, { "name": "Fin.isValue", "module": "Lean.Meta.Tactic.Simp.BuiltinSimprocs.Fin" }, { "name": "List.Vector.nil", "module": "Mathlib.Data.Vector.Defs" }, { "name": "Set.Mem", "module": "Mathlib.Data.Set.Defs" }, { "name": "Set.instMembership", "module": "Mathlib.Data.Set.Defs" }, { "name": "List.Vector.get", "module": "Mathlib.Data.Vector.Defs" }, { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Lean.ToExpr", "module": "Lean.ToExpr" } ]
[ { "name": "syntax \"max\" : MLIR.Pretty.uniform_op", "content": "syntax \"max\" : MLIR.Pretty.uniform_op" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = const ($x)\n $[: $outer_type]? ) => do\n let outer_type ← outer_type.getDM `(mlir_type| _)\n `(mlir_op| $res:mlir_op_operand = \"const\"()\n {val = $x:num : $outer_type} : ($outer_type) -> ($outer_type) )" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = li ($x)\n $[: $outer_type]? ) => do\n let outer_type ← outer_type.getDM `(mlir_type| _ )\n `(mlir_op| $res:mlir_op_operand = \"li\"()\n {imm = $x:num : $outer_type } : ($outer_type) -> ($outer_type))" }, { "name": "macro_rules", "content": "macro_rules\n| `(mlir_op| $res:mlir_op_operand = $op1:MLIR.Pretty.RV.opWithImmediate $reg1 , $x : $t) => do\n let some opName := MLIR.EDSL.Pretty.extractOpName op1.raw\n | Macro.throwUnsupported\n `(mlir_op| $res:mlir_op_operand = $opName ($reg1) {imm = $x:num : $t} : ($t) -> ($t) )" }, { "name": "macro_rules", "content": "macro_rules\n| `(mlir_op| $res:mlir_op_operand = $op1:MLIR.Pretty.RV.opWithShamt $reg1 , $x : $t ) => do\n let some opName := MLIR.EDSL.Pretty.extractOpName op1.raw\n | Macro.throwUnsupported\n `(mlir_op| $res:mlir_op_operand = $opName ($reg1) {shamt = $x:num : $t} : ($t) -> ($t) )" }, { "name": "Term", "content": "inductive Term : Type\n| var : Nat β†’ Term\n \n| zero : Term\n \n| negOne : Term\n \n| one : Term\n \n| ofNat (n : Nat) : Term\n \n| and : Term β†’ Term β†’ Term\n \n| or : Term β†’ Term β†’ Term\n \n| xor : Term β†’ Term β†’ Term\n \n| not : Term β†’ Term\n \n| add : Term β†’ Term β†’ Term\n \n| sub : Term β†’ Term β†’ Term\n \n| neg : Term β†’ Term\n\n\n \n| shiftL : Term β†’ Nat β†’ Term\n\n\nderiving Repr, Inhabited, Lean.ToExpr" }, { "name": "Term.arity", "content": "@[simp] def Term.arity : Term β†’ Nat\n| (var n) => n+1\n| zero => 0\n| one => 0\n| negOne => 0\n| ofNat _ => 0\n| Term.and t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| Term.or t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| Term.xor t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| Term.not t => arity t\n| add t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| sub t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| neg t => arity t\n\n\n| shiftL t .. => arity t" }, { "name": "BitVecs", "content": "structure BitVecs (n : Nat) where\n w : Nat\n bvs : List.Vector (BitVec w) n" }, { "name": "WidthPredicate", "content": "inductive WidthPredicate\n| eq\n| neq\n| lt\n| le\n| gt\n| ge\nderiving Repr, Inhabited, Lean.ToExpr" }, { "name": "BitVecs.transport", "content": "def BitVecs.transport (f : Fin n β†’ Fin m) (bvs : BitVecs m) : BitVecs n :=\n { w := bvs.w, bvs := bvs.bvs.transport f }" }, { "name": "BitVec.transport", "content": "def BitVec.transport (f : Fin n2 β†’ Fin n1) (bv : BitVec n1) : BitVec n2 :=\n BitVec.ofFn fun i => bv.getLsbD (f i)" }, { "name": "BitVec.ofFn", "content": "def BitVec.ofFn {w : Nat} (f : Fin w β†’ Bool) : BitVec w :=\n BitVec.iunfoldr (fun i _ => ((), f i)) () |>.2" }, { "name": "List.Vector.transport", "content": "def List.Vector.transport (v : Vector Ξ± m) (f : Fin n β†’ Fin m) : Vector Ξ± n :=\n Vector.ofFn fun i => v.get (f i)" }, { "name": "BitVecs'.transport", "content": "def BitVecs'.transport (f : Fin n β†’ Fin m) (bvs' : BitVecs' m): BitVecs' n :=\n bvs'.map fun bv => bv.transport f" }, { "name": "Valuation.cons", "content": "def Valuation.cons {Ξ“ : Ctxt Ty} {t : Ty} (x : toType t) (V : Ξ“.Valuation) :\n (Ξ“.cons t).Valuation :=" }, { "name": "BitVecs.cast", "content": "def BitVecs.cast (bvs : BitVecs n) (h : n = n') : BitVecs n' :=\n { w := bvs.w, bvs := h β–Έ bvs.bvs }" }, { "name": "infixr:67 \"::α΅₯\" => Valuation.cons", "content": "infixr:67 \"::α΅₯\" => Valuation.cons" } ]
[ { "name": "Nat.add_comm", "module": "Init.Data.Nat.Basic" }, { "name": "Fin.val_last", "module": "Init.Data.Fin.Lemmas" }, { "name": "Nat.mod_eq_of_lt", "module": "Init.Data.Nat.Div.Basic" }, { "name": "Set.mem_setOf_eq", "module": "Mathlib.Data.Set.Operations" }, { "name": "le_add_iff_nonneg_right", "module": "Mathlib.Algebra.Order.Monoid.Unbundled.Basic" }, { "name": "zero_le", "module": "Mathlib.Algebra.Order.Monoid.Canonical.Defs" } ]
[ { "name": "List.Vector.append_get_ge", "content": "@[simp]\nlemma List.Vector.append_get_ge {x : List.Vector Ξ± n} {y : List.Vector Ξ± m} {i : Fin (n+m)} (hlt: n ≀ i) :\n (x ++ y).get i = y.get ((i.cast (Nat.add_comm n m) |>.subNat n hlt))" }, { "name": "List.Vector.append_get_lt", "content": "@[simp]\nlemma List.Vector.append_get_lt {x : List.Vector Ξ± n} {y : List.Vector Ξ± m} {i : Fin (n+m)} (hlt: i < n) :\n (x ++ y).get i = x.get (i.castLT hlt)" }, { "name": "BitVecs.transport_getElem", "content": "@[simp]\nlemma BitVecs.transport_getElem {bvs : BitVecs m} (f : Fin n β†’ Fin m) (i : Fin n) :\n (bvs.transport f).bvs.get i = bvs.bvs.get (f i)" } ]
[ { "name": "liftMaxSucc1", "content": "def liftMaxSucc1 (n m : Nat) : Fin (n + 1) β†’ Fin (max n m + 2) :=\n fun k => if _ : k = n then Fin.last (max n m) else k.castLE (by admit /- proof elided -/\n )" }, { "name": "liftMaxSucc2", "content": "def liftMaxSucc2 (n m : Nat) : Fin (m + 1) β†’ Fin (max n m + 2) :=\n fun k => if _ : k = m then Fin.last (max n m + 1) else k.castLE (by admit /- proof elided -/\n )" }, { "name": "liftLast2", "content": "def liftLast2 n : Fin 2 β†’ Fin (n + 2)\n| 0 => n\n| 1 => Fin.last (n + 1)" }, { "name": "liftExcept2", "content": "def liftExcept2 n : Fin n β†’ Fin (n + 2) :=\n fun k => Fin.castLE (by admit /- proof elided -/\n ) k" }, { "name": "liftMax1", "content": "def liftMax1 (n m : Nat) : Fin n β†’ Fin (max n m) :=\n fun k => k.castLE (by admit /- proof elided -/\n )" }, { "name": "liftMax2", "content": "def liftMax2 (n m : Nat) : Fin m β†’ Fin (max n m) :=\n fun k => k.castLE (by admit /- proof elided -/\n )" }, { "name": "Term.evalFinBV", "content": "@[simp] def Term.evalFinBV (t : Term) (vars : Fin (arity t) β†’ BitVec w) : BitVec w :=\n match t with\n | .var n => vars (Fin.last n)\n | .zero => BitVec.zero w\n | .one => 1\n | .negOne => -1\n | .ofNat n => BitVec.ofNat _ n\n | .and t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ &&& xβ‚‚\n | .or t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ ||| xβ‚‚\n | .xor t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ ^^^ xβ‚‚\n | .not t => ~~~(t.evalFinBV vars)\n \n | .add t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ + xβ‚‚\n | .sub t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ - xβ‚‚\n | .neg t => -(t.evalFinBV vars)\n | .shiftL a n => (a.evalFinBV vars) <<< n" }, { "name": "Term.language", "content": "def Term.language (t : Term) : Set (BitVecs (t.arity + 1)) :=\n { bvs : BitVecs (t.arity + 1) | t.evalFinBV (fun n => bvs.bvs.get n) = bvs.bvs.get t.arity }" }, { "name": "RelationOrdering", "content": "inductive RelationOrdering\n| lt | le | gt | ge\nderiving Repr, Fintype" }, { "name": "Relation", "content": "inductive Relation\n| eq\n| signed (ord : RelationOrdering)\n| unsigned (ord : RelationOrdering)\nderiving Repr" }, { "name": "evalRelation", "content": "def evalRelation (rel : Relation) {w} (bv1 bv2 : BitVec w) : Prop :=\n match rel with\n | .eq => bv1 = bv2\n | .signed .lt => bv1.slt bv2\n | .signed .le => bv1.sle bv2\n | .signed .gt => bv2.slt bv1\n | .signed .ge => bv2.sle bv1\n | .unsigned .lt => bv1.ult bv2\n | .unsigned .le => bv1.ule bv2\n | .unsigned .gt => bv2.ult bv1\n | .unsigned .ge => bv2.ule bv1" }, { "name": "Relation.language", "content": "@[simp]\ndef Relation.language (rel : Relation) : Set (BitVecs 2) :=\n { bvs | evalRelation rel (bvs.bvs.get 0) (bvs.bvs.get 1) }" }, { "name": "Binop", "content": "inductive Binop\n| and | or | impl | equiv\nderiving Repr" }, { "name": "evalBinop", "content": "def evalBinop (op : Binop) (b1 b2 : Prop) : Prop :=\n match op with\n | .and => b1 ∧ b2\n | .or => b1 ∨ b2\n | .impl => b1 β†’ b2\n | .equiv => b1 ↔ b2" }, { "name": "langBinop", "content": "def langBinop (op : Binop) (l1 l2 : Set (BitVecs n)) : Set (BitVecs n) :=\n match op with\n | .and => l1 ∩ l2\n | .or => l1 βˆͺ l2\n | .impl => l1ᢜ βˆͺ l2\n | .equiv => (l1ᢜ βˆͺ l2) ∩ (l2ᢜ βˆͺ l1)" }, { "name": "Unop", "content": "inductive Unop\n| neg\nderiving Repr" }, { "name": "Formula", "content": "inductive Formula : Type\n| width : WidthPredicate β†’ Nat β†’ Formula\n| atom : Relation β†’ Term β†’ Term β†’ Formula\n| msbSet : Term β†’ Formula\n| unop : Unop β†’ Formula β†’ Formula\n| binop : Binop β†’ Formula β†’ Formula β†’ Formula\nderiving Repr" }, { "name": "Formula.arity", "content": "@[simp]\ndef Formula.arity : Formula β†’ Nat\n| width _ _ => 0\n| atom _ t1 t2 => max t1.arity t2.arity\n| msbSet t => t.arity\n| unop _ Ο† => Ο†.arity\n| binop _ Ο†1 Ο†2 => max Ο†1.arity Ο†2.arity" }, { "name": "WidthPredicate.sat", "content": "@[simp]\ndef WidthPredicate.sat (wp : WidthPredicate) (w n : Nat) : Bool :=\n match wp with\n | .eq => w = n\n | .neq => w β‰  n\n | .lt => w < n\n | .le => w ≀ n\n | .gt => w > n\n | .ge => w β‰₯ n" }, { "name": "Formula.sat", "content": "@[simp]\ndef Formula.sat {w : Nat} (Ο† : Formula) (ρ : Fin Ο†.arity β†’ BitVec w) : Prop :=\n match Ο† with\n | .width wp n => wp.sat w n\n | .atom rel t1 t2 =>\n let bv1 := t1.evalFinBV (fun n => ρ $ Fin.castLE (by admit /- proof elided -/\n ) n)\n let bv2 := t2.evalFinBV (fun n => ρ $ Fin.castLE (by admit /- proof elided -/\n ) n)\n evalRelation rel bv1 bv2\n | .unop .neg Ο† => Β¬ Ο†.sat ρ\n | .binop op Ο†1 Ο†2 =>\n let b1 := Ο†1.sat (fun n => ρ $ Fin.castLE (by admit /- proof elided -/\n ) n)\n let b2 := Ο†2.sat (fun n => ρ $ Fin.castLE (by admit /- proof elided -/\n ) n)\n evalBinop op b1 b2\n | .msbSet t => (t.evalFinBV ρ).msb" }, { "name": "_root_.Set.lift", "content": "@[simp]\ndef _root_.Set.lift (f : Fin n β†’ Fin m) (bvs : Set (BitVecs n)) : Set (BitVecs m) :=\n BitVecs.transport f ⁻¹' bvs" }, { "name": "_root_.Set.proj", "content": "@[simp]\ndef _root_.Set.proj (f : Fin n β†’ Fin m) (bvs : Set (BitVecs m)) : Set (BitVecs n) :=\n BitVecs.transport f '' bvs" }, { "name": "Formula.language", "content": "@[simp]\ndef Formula.language (Ο† : Formula) : Set (BitVecs Ο†.arity) :=\n match Ο† with\n | .width wp n => { bvs | wp.sat bvs.w n }\n | .atom rel t1 t2 =>\n let l1 := t1.language.lift (liftMaxSucc1 (FinEnum.card $ Fin t1.arity) (FinEnum.card $ Fin t2.arity))\n let l2 := t2.language.lift (liftMaxSucc2 (FinEnum.card $ Fin t1.arity) (FinEnum.card $ Fin t2.arity))\n let lrel := rel.language.lift $ liftLast2 (max (FinEnum.card (Fin t1.arity)) (FinEnum.card (Fin t2.arity)))\n let l := lrel ∩ l1 ∩ l2\n l.proj (liftExcept2 _)\n | .unop .neg Ο† => Ο†.languageᢜ\n | .binop op Ο†1 Ο†2 =>\n let l1 := Ο†1.language.lift $ liftMax1 Ο†1.arity Ο†2.arity\n let l2 := Ο†2.language.lift $ liftMax2 Ο†1.arity Ο†2.arity\n langBinop op l1 l2\n | .msbSet t =>\n let lmsb := langMsb.lift $ fun _ => Fin.last t.arity\n let l' := t.language ∩ lmsb\n l'.proj fun n => n.castLE (by admit /- proof elided -/\n )" } ]
[ { "name": "evalFin_eq", "content": "lemma evalFin_eq {t : Term} {vars1 : Fin t.arity β†’ BitVec w1} {vars2 : Fin t.arity β†’ BitVec w2} :\n βˆ€ (heq : w1 = w2),\n (βˆ€ n, vars1 n = heq β–Έ vars2 n) β†’\n t.evalFinBV vars1 = heq β–Έ t.evalFinBV vars2" }, { "name": "evalRelation_coe", "content": "@[simp]\nlemma evalRelation_coe (rel : Relation) (bv1 bv2 : BitVec w1) (heq : w1 = w2) :\n evalRelation rel (heq β–Έ bv1) (heq β–Έ bv2) = evalRelation rel bv1 bv2" }, { "name": "helper1", "content": "lemma helper1 : (k = 0) β†’ (x ::α΅₯ vs).get k = x" }, { "name": "helper2", "content": "lemma helper2 : (k = 1) β†’ (x ::α΅₯ y ::α΅₯ vs).get k = y" } ]
import Blase.AutoStructs.ForMathlib import Blase.SingleWidth.Defs open Fin.NatCast def liftMaxSucc1 (n m : Nat) : Fin (n + 1) β†’ Fin (max n m + 2) := fun k => if _ : k = n then Fin.last (max n m) else k.castLE (by admit /- proof elided -/ ) def liftMaxSucc2 (n m : Nat) : Fin (m + 1) β†’ Fin (max n m + 2) := fun k => if _ : k = m then Fin.last (max n m + 1) else k.castLE (by admit /- proof elided -/ ) def liftLast2 n : Fin 2 β†’ Fin (n + 2) | 0 => n | 1 => Fin.last (n + 1) def liftExcept2 n : Fin n β†’ Fin (n + 2) := fun k => Fin.castLE (by admit /- proof elided -/ ) k def liftMax1 (n m : Nat) : Fin n β†’ Fin (max n m) := fun k => k.castLE (by admit /- proof elided -/ ) def liftMax2 (n m : Nat) : Fin m β†’ Fin (max n m) := fun k => k.castLE (by admit /- proof elided -/ ) @[simp] def Term.evalFinBV (t : Term) (vars : Fin (arity t) β†’ BitVec w) : BitVec w := match t with | .var n => vars (Fin.last n) | .zero => BitVec.zero w | .one => 1 | .negOne => -1 | .ofNat n => BitVec.ofNat _ n | .and t₁ tβ‚‚ => let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) x₁ &&& xβ‚‚ | .or t₁ tβ‚‚ => let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) x₁ ||| xβ‚‚ | .xor t₁ tβ‚‚ => let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) x₁ ^^^ xβ‚‚ | .not t => ~~~(t.evalFinBV vars) | .add t₁ tβ‚‚ => let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) x₁ + xβ‚‚ | .sub t₁ tβ‚‚ => let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/ ) i)) x₁ - xβ‚‚ | .neg t => -(t.evalFinBV vars) | .shiftL a n => (a.evalFinBV vars) <<< n def Term.language (t : Term) : Set (BitVecs (t.arity + 1)) := { bvs : BitVecs (t.arity + 1) | t.evalFinBV (fun n => bvs.bvs.get n) = bvs.bvs.get t.arity } inductive RelationOrdering | lt | le | gt | ge deriving Repr, Fintype inductive Relation | eq | signed (ord : RelationOrdering) | unsigned (ord : RelationOrdering) deriving Repr def evalRelation (rel : Relation) {w} (bv1 bv2 : BitVec w) : Prop := match rel with | .eq => bv1 = bv2 | .signed .lt => bv1.slt bv2 | .signed .le => bv1.sle bv2 | .signed .gt => bv2.slt bv1 | .signed .ge => bv2.sle bv1 | .unsigned .lt => bv1.ult bv2 | .unsigned .le => bv1.ule bv2 | .unsigned .gt => bv2.ult bv1 | .unsigned .ge => bv2.ule bv1 @[simp] def Relation.language (rel : Relation) : Set (BitVecs 2) := { bvs | evalRelation rel (bvs.bvs.get 0) (bvs.bvs.get 1) } inductive Binop | and | or | impl | equiv deriving Repr def evalBinop (op : Binop) (b1 b2 : Prop) : Prop := match op with | .and => b1 ∧ b2 | .or => b1 ∨ b2 | .impl => b1 β†’ b2 | .equiv => b1 ↔ b2 def langBinop (op : Binop) (l1 l2 : Set (BitVecs n)) : Set (BitVecs n) := match op with | .and => l1 ∩ l2 | .or => l1 βˆͺ l2 | .impl => l1ᢜ βˆͺ l2 | .equiv => (l1ᢜ βˆͺ l2) ∩ (l2ᢜ βˆͺ l1) inductive Unop | neg deriving Repr inductive Formula : Type | width : WidthPredicate β†’ Nat β†’ Formula | atom : Relation β†’ Term β†’ Term β†’ Formula | msbSet : Term β†’ Formula | unop : Unop β†’ Formula β†’ Formula | binop : Binop β†’ Formula β†’ Formula β†’ Formula deriving Repr @[simp] def Formula.arity : Formula β†’ Nat | width _ _ => 0 | atom _ t1 t2 => max t1.arity t2.arity | msbSet t => t.arity | unop _ Ο† => Ο†.arity | binop _ Ο†1 Ο†2 => max Ο†1.arity Ο†2.arity @[simp] def WidthPredicate.sat (wp : WidthPredicate) (w n : Nat) : Bool := match wp with | .eq => w = n | .neq => w β‰  n | .lt => w < n | .le => w ≀ n | .gt => w > n | .ge => w β‰₯ n @[simp] def Formula.sat {w : Nat} (Ο† : Formula) (ρ : Fin Ο†.arity β†’ BitVec w) : Prop := match Ο† with | .width wp n => wp.sat w n | .atom rel t1 t2 => let bv1 := t1.evalFinBV (fun n => ρ $ Fin.castLE (by admit /- proof elided -/ ) n) let bv2 := t2.evalFinBV (fun n => ρ $ Fin.castLE (by admit /- proof elided -/ ) n) evalRelation rel bv1 bv2 | .unop .neg Ο† => Β¬ Ο†.sat ρ | .binop op Ο†1 Ο†2 => let b1 := Ο†1.sat (fun n => ρ $ Fin.castLE (by admit /- proof elided -/ ) n) let b2 := Ο†2.sat (fun n => ρ $ Fin.castLE (by admit /- proof elided -/ ) n) evalBinop op b1 b2 | .msbSet t => (t.evalFinBV ρ).msb @[simp] def _root_.Set.lift (f : Fin n β†’ Fin m) (bvs : Set (BitVecs n)) : Set (BitVecs m) := BitVecs.transport f ⁻¹' bvs @[simp] def _root_.Set.proj (f : Fin n β†’ Fin m) (bvs : Set (BitVecs m)) : Set (BitVecs n) := BitVecs.transport f '' bvs @[simp] def Formula.language (Ο† : Formula) : Set (BitVecs Ο†.arity) := match Ο† with | .width wp n => { bvs | wp.sat bvs.w n } | .atom rel t1 t2 => let l1 := t1.language.lift (liftMaxSucc1 (FinEnum.card $ Fin t1.arity) (FinEnum.card $ Fin t2.arity)) let l2 := t2.language.lift (liftMaxSucc2 (FinEnum.card $ Fin t1.arity) (FinEnum.card $ Fin t2.arity)) let lrel := rel.language.lift $ liftLast2 (max (FinEnum.card (Fin t1.arity)) (FinEnum.card (Fin t2.arity))) let l := lrel ∩ l1 ∩ l2 l.proj (liftExcept2 _) | .unop .neg Ο† => Ο†.languageᢜ | .binop op Ο†1 Ο†2 => let l1 := Ο†1.language.lift $ liftMax1 Ο†1.arity Ο†2.arity let l2 := Ο†2.language.lift $ liftMax2 Ο†1.arity Ο†2.arity langBinop op l1 l2 | .msbSet t => let lmsb := langMsb.lift $ fun _ => Fin.last t.arity let l' := t.language ∩ lmsb l'.proj fun n => n.castLE (by admit /- proof elided -/ )
lemma formula_language_case_atom : let Ο† :=
:= Formula.atom rel t1 t2 Ο†.language = Ξ» (bvs : BitVecs Ο†.arity) => Ο†.sat (fun k => bvs.bvs.get k) := by unfold Formula.language rintro Ο† let n := Ο†.arity unfold Ο† dsimp (config := { zeta := false }) lift_lets intros l1 l2 lrel l ext bvs constructor Β· intros h; simp at h obtain ⟨bvsb, h, heqb⟩ := h unfold l at h simp at h unfold lrel l1 l2 at h obtain ⟨⟨hrel, h1⟩, h2⟩ := h have _ : n+1 < bvsb.bvs.length := by simp +zetaDelta have _ : n < bvsb.bvs.length := by simp +zetaDelta have hrel : evalRelation rel (bvsb.bvs.get n) (bvsb.bvs.get (Fin.last (n + 1))) := by simp at hrel apply hrel have ht1 : bvsb.bvs.get n = t1.evalFinBV fun n => bvsb.bvs.get n := by unfold Term.language at h1 simp [liftMaxSucc1] at h1 unfold n; simp +zetaDelta; rw [←h1] congr; ext1 k congr; ext; simp; rw [Nat.mod_eq_of_lt]; omega have ht2 : bvsb.bvs.get (Fin.last (n+1)) = t2.evalFinBV fun n => bvsb.bvs.get n := by unfold Term.language at h2 simp [liftMaxSucc2] at h2 unfold n; simp +zetaDelta only [Formula.arity]; rw [←h2] congr; ext1 k congr; ext; simp; rw [Nat.mod_eq_of_lt]; omega have hw : bvsb.w = bvs.w := by rw [←heqb]; simp have heq1 : (t1.evalFinBV fun n => bvsb.bvs.get n) = hw β–Έ t1.evalFinBV fun n => bvs.bvs.get $ n.castLE (by simp) := by apply evalFin_eq hw; intros k rcases bvs with ⟨w, bvs⟩; rcases hw injection heqb with _ heqb; rw [←heqb] simp [List.Vector.transport, liftExcept2] congr; ext; simp; omega have heq2 : (t2.evalFinBV fun n => bvsb.bvs.get n) = hw β–Έ t2.evalFinBV fun n => bvs.bvs.get $ n.castLE (by simp) := by apply evalFin_eq hw; intros k rcases bvs with ⟨w, bvs⟩; rcases hw injection heqb with _ heqb; rw [←heqb] simp [List.Vector.transport, liftExcept2] congr; ext; simp; omega rw [ht1, ht2, heq1, heq2, evalRelation_coe] at hrel dsimp only [Set.instMembership, Set.Mem] simp_all Β· intros h simp let bv1 := t1.evalFinBV fun k => bvs.bvs.get $ k.castLE (by simp) let bv2 := t2.evalFinBV fun k => bvs.bvs.get $ k.castLE (by simp) use ⟨bvs.w, bvs.bvs ++ bv1 ::α΅₯ bv2 ::α΅₯ List.Vector.nil⟩ rcases bvs with ⟨w, bvs⟩ simp constructor Β· unfold l; simp; split_ands Β· unfold lrel; simp only [Fin.isValue, BitVecs.transport_getElem, liftLast2, Set.mem_setOf_eq, Fin.val_last, le_add_iff_nonneg_right, zero_le, List.Vector.append_get_ge] rw [List.Vector.append_get_ge (by dsimp; rw [Nat.mod_eq_of_lt]; omega)] simp [Set.instMembership, Set.Mem] at h convert h using 2 Β· apply helper1; ext; simp; rw [Nat.mod_eq_of_lt] <;> omega Β· apply helper2; ext; simp Β· unfold l1 Term.language; simp [liftMaxSucc1] rw [List.Vector.append_get_ge (by dsimp; rw [Nat.mod_eq_of_lt]; omega)] rw [helper1 (by ext; simp; rw [Nat.mod_eq_of_lt] <;> omega)] unfold bv1 congr; Β· unfold l2 Term.language; simp [liftMaxSucc2] rw [helper2 (by ext; simp)] unfold bv2 congr Β· ext1; simp next i => simp [liftExcept2] rw [List.Vector.append_get_lt i.isLt] congr 1
5
73
false
Compiler
297
TermBinop.alt_lang
lemma TermBinop.alt_lang {t₁ tβ‚‚ : Term} (op : TermBinop) : (op.subst_arity' β–Έ (op.subst t₁ tβ‚‚).language) = let lop : Set (BitVecs 3) := op.openTerm_arity β–Έ op.openTerm.language let lop' : Set (BitVecs ((t₁.arity βŠ” tβ‚‚.arity) + 3)) := lop.lift (liftLast3 (max t₁.arity tβ‚‚.arity)) let l₁ := t₁.language.lift (liftMaxSuccSucc1 t₁.arity tβ‚‚.arity) let lβ‚‚ := tβ‚‚.language.lift (liftMaxSuccSucc2 t₁.arity tβ‚‚.arity) let l := l₁ ∩ lβ‚‚ ∩ lop' l.proj (liftOp _)
lean-mlir
Blase/Blase/AutoStructs/FormulaToAuto.lean
[ "import Blase.SingleWidth.Defs", "import Blase.AutoStructs.Constructions", "import Blase.Blase.Fast.BitStream", "import Mathlib.Data.Nat.Size -- TODO: remove and get rid of shiftLeft_eq_mul_pow use", "import Blase.Blase.AutoStructs.ForMathlib", "import Blase.AutoStructs.Defs", "import Mathlib.Tactic.FinCases", "import Mathlib.Data.BitVec", "import Mathlib.Tactic.Ring", "import Blase.AutoStructs.FiniteStateMachine", "import Batteries.Data.Fin.Lemmas", "import Batteries.Data.Fin.Basic" ]
[ { "name": "Inhabited", "module": "Init.Prelude" }, { "name": "Lean.ToExpr", "module": "Lean.ToExpr" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Repr", "module": "Init.Data.Repr" }, { "name": "Bool", "module": "Init.Prelude" }, { "name": "Int.xor", "module": "Mathlib.Data.Int.Bitwise" }, { "name": "BitVec", "module": "Init.Prelude" }, { "name": "BitVec.adcb", "module": "Init.Data.BitVec.Bitblast" }, { "name": "Prod", "module": "Init.Prelude" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "Fin.last", "module": "Init.Data.Fin.Basic" }, { "name": "Fin.mk", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "List.Vector", "module": "Mathlib.Data.Vector.Defs" }, { "name": "BitVec.ofNat", "module": "Init.Prelude" }, { "name": "BitVec.zero", "module": "Init.Data.BitVec.Basic" }, { "name": "Fin.castLE", "module": "Init.Data.Fin.Basic" }, { "name": "Set", "module": "Mathlib.Data.Set.Defs" }, { "name": "Fin.cast", "module": "Init.Data.Fin.Basic" }, { "name": "Fin.castLT", "module": "Init.Data.Fin.Basic" }, { "name": "Fin.subNat", "module": "Init.Data.Fin.Basic" }, { "name": "List.Vector.get", "module": "Mathlib.Data.Vector.Defs" }, { "name": "List.Vector.nil", "module": "Mathlib.Data.Vector.Defs" } ]
[ { "name": "syntax \"xor\" : MLIR.Pretty.uniform_op", "content": "syntax \"xor\" : MLIR.Pretty.uniform_op\n\nsyntax \"max\" : MLIR.Pretty.uniform_op" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = const ($x)\n $[: $outer_type]? ) => do\n let outer_type ← outer_type.getDM `(mlir_type| _)\n `(mlir_op| $res:mlir_op_operand = \"const\"()\n {val = $x:num : $outer_type} : ($outer_type) -> ($outer_type) )" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = li ($x)\n $[: $outer_type]? ) => do\n let outer_type ← outer_type.getDM `(mlir_type| _ )\n `(mlir_op| $res:mlir_op_operand = \"li\"()\n {imm = $x:num : $outer_type } : ($outer_type) -> ($outer_type))" }, { "name": "macro_rules", "content": "macro_rules\n| `(mlir_op| $res:mlir_op_operand = $op1:MLIR.Pretty.RV.opWithImmediate $reg1 , $x : $t) => do\n let some opName := MLIR.EDSL.Pretty.extractOpName op1.raw\n | Macro.throwUnsupported\n `(mlir_op| $res:mlir_op_operand = $opName ($reg1) {imm = $x:num : $t} : ($t) -> ($t) )" }, { "name": "macro_rules", "content": "macro_rules\n| `(mlir_op| $res:mlir_op_operand = $op1:MLIR.Pretty.RV.opWithShamt $reg1 , $x : $t ) => do\n let some opName := MLIR.EDSL.Pretty.extractOpName op1.raw\n | Macro.throwUnsupported\n `(mlir_op| $res:mlir_op_operand = $opName ($reg1) {shamt = $x:num : $t} : ($t) -> ($t) )" }, { "name": "Term", "content": "inductive Term : Type\n| var : Nat β†’ Term\n \n| zero : Term\n \n| negOne : Term\n \n| one : Term\n \n| ofNat (n : Nat) : Term\n \n| and : Term β†’ Term β†’ Term\n \n| or : Term β†’ Term β†’ Term\n \n| xor : Term β†’ Term β†’ Term\n \n| not : Term β†’ Term\n \n| add : Term β†’ Term β†’ Term\n \n| sub : Term β†’ Term β†’ Term\n \n| neg : Term β†’ Term\n\n\n \n| shiftL : Term β†’ Nat β†’ Term\n\n\nderiving Repr, Inhabited, Lean.ToExpr" }, { "name": "neg", "content": "def neg (x : BitStream) : BitStream :=\n fun n => (negAux x n).1" }, { "name": "negAux", "content": "def negAux (x : BitStream) : Nat β†’ Bool Γ— Bool\n | 0 => (x 0, !(x 0))\n | n+1 =>\n let borrow := (negAux x n).2\n let a := x (n + 1)\n (xor (!a) borrow, !a && borrow)" }, { "name": "BitStream", "content": "def BitStream : Type := Nat β†’ Bool" }, { "name": "sub", "content": "def sub (x y : BitStream) : BitStream :=\n fun n => (subAux x y n).1" }, { "name": "subAux", "content": "def subAux (x y : BitStream) : Nat β†’ Bool Γ— Bool\n | 0 => (xor (x 0) (y 0), !(x 0) && y 0)\n | n+1 =>\n let borrow := (subAux x y n).2\n let a := x (n + 1)\n let b := y (n + 1)\n (xor a (xor b borrow), !a && b || ((!(xor a b)) && borrow))" }, { "name": "add", "content": "def add (x y : BitStream) : BitStream :=\n fun n => (addAux x y n).1" }, { "name": "addAux", "content": "def addAux (x y : BitStream) (i : Nat) : Bool Γ— Bool :=\n let carryIn : Bool := match i with\n | 0 => false\n | i + 1 => (addAux x y i).2\n Prod.swap (BitVec.adcb (x i) (y i) carryIn)" }, { "name": "BitVecs", "content": "structure BitVecs (n : Nat) where\n w : Nat\n bvs : List.Vector (BitVec w) n" }, { "name": "liftMaxSuccSucc2", "content": "def liftMaxSuccSucc2 (n m : Nat) : Fin (m + 1) β†’ Fin (max n m + 3) :=\n fun k => if _ : k = Fin.last m then max n m + 1 else k.castLE (by admit /- proof elided -/\n )" }, { "name": "liftMaxSuccSucc1", "content": "def liftMaxSuccSucc1 (n m : Nat) : Fin (n + 1) β†’ Fin (max n m + 3) :=\n fun k => if _ : k = Fin.last n then (max n m).cast else k.castLE (by admit /- proof elided -/\n )" }, { "name": "liftLast3", "content": "def liftLast3 n : Fin 3 β†’ Fin (n + 3)\n| 0 => n\n| 1 => n + 1\n| 2 => Fin.last (n + 2)" }, { "name": "BitVecs.cast", "content": "def BitVecs.cast (bvs : BitVecs n) (h : n = n') : BitVecs n' :=\n { w := bvs.w, bvs := h β–Έ bvs.bvs }" }, { "name": "Valuation.cons", "content": "def Valuation.cons {Ξ“ : Ctxt Ty} {t : Ty} (x : toType t) (V : Ξ“.Valuation) :\n (Ξ“.cons t).Valuation :=" }, { "name": "Term.language", "content": "def Term.language (t : Term) : Set (BitVecs (t.arity + 1)) :=\n { bvs : BitVecs (t.arity + 1) | t.evalFinBV (fun n => bvs.bvs.get n) = bvs.bvs.get t.arity }" }, { "name": "Formula.arity", "content": "@[simp]\ndef Formula.arity : Formula β†’ Nat\n| width _ _ => 0\n| atom _ t1 t2 => max t1.arity t2.arity\n| msbSet t => t.arity\n| unop _ Ο† => Ο†.arity\n| binop _ Ο†1 Ο†2 => max Ο†1.arity Ο†2.arity" }, { "name": "Term.evalFinBV", "content": "@[simp] def Term.evalFinBV (t : Term) (vars : Fin (arity t) β†’ BitVec w) : BitVec w :=\n match t with\n | .var n => vars (Fin.last n)\n | .zero => BitVec.zero w\n | .one => 1\n | .negOne => -1\n | .ofNat n => BitVec.ofNat _ n\n | .and t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ &&& xβ‚‚\n | .or t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ ||| xβ‚‚\n | .xor t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ ^^^ xβ‚‚\n | .not t => ~~~(t.evalFinBV vars)\n \n | .add t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ + xβ‚‚\n | .sub t₁ tβ‚‚ =>\n let x₁ := t₁.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n let xβ‚‚ := tβ‚‚.evalFinBV (fun i => vars (Fin.castLE (by admit /- proof elided -/\n ) i))\n x₁ - xβ‚‚\n | .neg t => -(t.evalFinBV vars)\n | .shiftL a n => (a.evalFinBV vars) <<< n" }, { "name": "Term.arity", "content": "@[simp] def Term.arity : Term β†’ Nat\n| (var n) => n+1\n| zero => 0\n| one => 0\n| negOne => 0\n| ofNat _ => 0\n| Term.and t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| Term.or t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| Term.xor t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| Term.not t => arity t\n| add t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| sub t₁ tβ‚‚ => max (arity t₁) (arity tβ‚‚)\n| neg t => arity t\n\n\n| shiftL t .. => arity t" }, { "name": "infixr:67 \"::α΅₯\" => Valuation.cons", "content": "infixr:67 \"::α΅₯\" => Valuation.cons" } ]
[ { "name": "Nat.add_comm", "module": "Init.Data.Nat.Basic" }, { "name": "Fin.add_def", "module": "Init.Data.Fin.Lemmas" }, { "name": "Fin.castLE_castLE", "module": "Init.Data.Fin.Lemmas" }, { "name": "Nat.le_of_eq", "module": "Init.Data.Nat.Basic" }, { "name": "Nat.mod_eq_of_lt", "module": "Init.Data.Nat.Div.Basic" } ]
[ { "name": "List.Vector.append_get_ge", "content": "@[simp]\nlemma List.Vector.append_get_ge {x : List.Vector Ξ± n} {y : List.Vector Ξ± m} {i : Fin (n+m)} (hlt: n ≀ i) :\n (x ++ y).get i = y.get ((i.cast (Nat.add_comm n m) |>.subNat n hlt))" }, { "name": "List.Vector.append_get_lt", "content": "@[simp]\nlemma List.Vector.append_get_lt {x : List.Vector Ξ± n} {y : List.Vector Ξ± m} {i : Fin (n+m)} (hlt: i < n) :\n (x ++ y).get i = x.get (i.castLT hlt)" }, { "name": "ext", "content": "@[ext]\ntheorem ext {x y : BitStream} (h : βˆ€ i, x i = y i) : x = y" } ]
[ { "name": "liftOp", "content": "def liftOp n : Fin (n + 1) β†’ Fin (n + 3) :=\n fun k =>\n if k = n then Fin.last (n+2) else k.castLE (by admit /- proof elided -/\n )" }, { "name": "liftOp_unchanged", "content": "@[simp]\ndef liftOp_unchanged (k : Fin n) : liftOp n k.castSucc = k.castLE (by simp) :=" }, { "name": "TermBinop", "content": "inductive TermBinop where\n| and | or | xor | add | sub" }, { "name": "TermBinop.subst", "content": "def TermBinop.subst (op : TermBinop) (t₁ tβ‚‚ : Term) : Term :=\n match op with\n | .and => .and t₁ tβ‚‚\n | .or => .or t₁ tβ‚‚\n | .xor => .xor t₁ tβ‚‚\n | .add => .add t₁ tβ‚‚\n | .sub => .sub t₁ tβ‚‚" }, { "name": "TermBinop.openTerm", "content": "def TermBinop.openTerm (op : TermBinop) : Term := op.subst (.var 0) (.var 1)" }, { "name": "TermBinop.openTerm_arity", "content": "@[simp]\ndef TermBinop.openTerm_arity (op : TermBinop) : op.openTerm.arity + 1 = 3 :=" }, { "name": "swapLastTwoBlock", "content": "def swapLastTwoBlock (x : Fin (n + 3)) : Fin (n + 3) :=\n if x = Fin.last (n+2) then n\n else if x = n+1 then Fin.last (n + 2)\n else if x = n then n + 1\n else x" } ]
[ { "name": "TermBinop.subst_arity'", "content": "lemma TermBinop.subst_arity' {op : TermBinop} : (op.subst t₁ tβ‚‚).arity + 1= t₁.arity βŠ” tβ‚‚.arity + 1" }, { "name": "BitVecs.cast_eq", "content": "@[simp]\nlemma BitVecs.cast_eq (x : BitVecs n) (h : n = n') : h β–Έ x = x.cast h" } ]
import Batteries.Data.Fin.Basic import Batteries.Data.Fin.Lemmas import Blase.SingleWidth.Defs import Blase.AutoStructs.Constructions import Blase.AutoStructs.Defs import Blase.AutoStructs.FiniteStateMachine import Mathlib.Tactic.Ring import Mathlib.Data.Nat.Size -- TODO: remove and get rid of shiftLeft_eq_mul_pow use import Mathlib.Data.BitVec import Mathlib.Tactic.FinCases open Fin.NatCast open Mathlib section fsm variable {arity : Type} [FinEnum arity] open BitStream in end fsm section nfas_relations end nfas_relations def liftOp n : Fin (n + 1) β†’ Fin (n + 3) := fun k => if k = n then Fin.last (n+2) else k.castLE (by admit /- proof elided -/ ) @[simp] def liftOp_unchanged (k : Fin n) : liftOp n k.castSucc = k.castLE (by simp) := inductive TermBinop where | and | or | xor | add | sub def TermBinop.subst (op : TermBinop) (t₁ tβ‚‚ : Term) : Term := match op with | .and => .and t₁ tβ‚‚ | .or => .or t₁ tβ‚‚ | .xor => .xor t₁ tβ‚‚ | .add => .add t₁ tβ‚‚ | .sub => .sub t₁ tβ‚‚ def TermBinop.openTerm (op : TermBinop) : Term := op.subst (.var 0) (.var 1) @[simp] def TermBinop.openTerm_arity (op : TermBinop) : op.openTerm.arity + 1 = 3 := def swapLastTwoBlock (x : Fin (n + 3)) : Fin (n + 3) := if x = Fin.last (n+2) then n else if x = n+1 then Fin.last (n + 2) else if x = n then n + 1 else x
lemma TermBinop.alt_lang {t₁ tβ‚‚ : Term} (op : TermBinop) : (op.subst_arity' β–Έ (op.subst t₁ tβ‚‚).language) = let lop : Set (BitVecs 3) :=
:= op.openTerm_arity β–Έ op.openTerm.language let lop' : Set (BitVecs ((t₁.arity βŠ” tβ‚‚.arity) + 3)) := lop.lift (liftLast3 (max t₁.arity tβ‚‚.arity)) let l₁ := t₁.language.lift (liftMaxSuccSucc1 t₁.arity tβ‚‚.arity) let lβ‚‚ := tβ‚‚.language.lift (liftMaxSuccSucc2 t₁.arity tβ‚‚.arity) let l := l₁ ∩ lβ‚‚ ∩ lop' l.proj (liftOp _) := by simp [Term.language] ext bvs simp constructor Β· rintro heq let bvs' := bvs.bvs ++ (t₁.evalFinBV (Ξ» n ↦ bvs.bvs.get n) ::α΅₯ tβ‚‚.evalFinBV (Ξ» n ↦ bvs.bvs.get n) ::α΅₯ List.Vector.nil) |>.transport swapLastTwoBlock use ⟨_, bvs'⟩ simp [bvs'] split_ands Β· rw [liftMaxSuccSucc1]; simp conv => enter [1, 2, n] rw [List.Vector.append_get_lt (by rcases n with ⟨n, hn⟩; simp_all; rw [Nat.mod_eq_of_lt (by omega)]; omega)] rfl rw [List.Vector.append_get_ge] on_goal 2 => apply Nat.le_of_eq; simp [Fin.add_def]; rw [Nat.mod_eq_of_lt (by omega)] generalize_proofs h₁ hβ‚‚ h₃ hβ‚„ have heq h : Fin.subNat (t₁.arity βŠ” tβ‚‚.arity + 1) (Fin.cast hβ‚„ (↑(t₁.arity βŠ” tβ‚‚.arity) + 1)) h = 0 := by ext; simp [Fin.add_def]; rw [Nat.mod_eq_of_lt (by omega)]; omega simp [heq] congr; ext1 i; congr 1 rcases i with ⟨i, hi⟩; simp [Fin.castLT]; ext; simp; repeat rw [Nat.mod_eq_of_lt (by omega)] Β· rw [liftMaxSuccSucc2]; simp conv => enter [1, 2, n] rw [List.Vector.append_get_lt (by rcases n with ⟨n, hn⟩; simp_all; rw [Nat.mod_eq_of_lt (by omega)]; omega)] rfl generalize_proofs h₁ hβ‚‚ h₃ hβ‚„ have heq h : Fin.subNat (t₁.arity βŠ” tβ‚‚.arity + 1) (Fin.last (2 + t₁.arity βŠ” tβ‚‚.arity)) h = 1 := by ext; simp; omega simp [heq] congr; ext1 i; congr 1 rcases i with ⟨i, hi⟩; simp [Fin.castLT]; ext; simp; repeat rw [Nat.mod_eq_of_lt (by omega)] Β· rw [BitVecs.cast_eq] at * simp [BitVecs.cast] at * rw [liftLast3] simp rw [List.Vector.append_get_lt (by simp; rw [Nat.mod_eq_of_lt (by omega)]; omega)] convert heq using 1 have h n : n + 1 < n + 3 := by omega have h' n m k : n < m β†’ n < (k βŠ” m) + 1 := by omega Β· cases op <;> Β· simp [openTerm, subst, liftLast3]; congr Β· rw [List.Vector.append_get_ge] Β· simp [Fin.subNat, Fin.add_def]; simp [Nat.mod_eq_of_lt, h]; congr! with ⟨n, hn⟩; ext; simp; omega Β· rw [Fin.add_def]; simp; rw [Nat.mod_eq_of_lt (by omega)] Β· have heq h : (Fin.subNat (t₁.arity βŠ” tβ‚‚.arity + 1) (Fin.last (2 + t₁.arity βŠ” tβ‚‚.arity)) h) = 1 := by simp [Fin.subNat]; omega simp [heq, List.Vector.get]; congr; ext1 ⟨i, hi⟩; simp; simp [Nat.mod_eq_of_lt (h' _ _ t₁.arity hi)] Β· congr!; simp [Fin.castLT, Fin.last]; omega Β· ext1 Β· simp next i => simp [liftOp] split_ifs with h Β· subst h simp rw [List.Vector.append_get_lt] on_goal 2 => simp +arith repeat (rw [Nat.mod_eq_of_lt (by omega)]) omega congr; ext; simp +arith omega Β· simp [h] rw [List.Vector.append_get_lt (by rcases i; simp_all [Fin.last]; rw [Nat.mod_eq_of_lt (by omega)]; omega)] rcases i with ⟨i, hi⟩; congr!; simp_all; omega Β· rintro ⟨bvs', ⟨⟨⟨heq₁, heqβ‚‚βŸ©, heqβ‚ƒβŸ©, heqβ‚„βŸ©βŸ© rw [BitVecs.cast_eq] at * simp [BitVecs.cast] at * rw [←heqβ‚„] conv_rhs => simp simp [liftOp] rfl simp [liftMaxSuccSucc1, liftMaxSuccSucc2] at heq₁ heqβ‚‚ rw [liftLast3] at heq₃ convert heq₃ using 1 have h₁ : (t₁.evalFinBV fun i => bvs'.bvs.get (liftOp (t₁.arity βŠ” tβ‚‚.arity) (Fin.castLE (by omega) i).castSucc)) = bvs'.bvs.get (liftLast3 (t₁.arity βŠ” tβ‚‚.arity) 0) := by simp only [liftOp_unchanged, Fin.castLE_castLE, liftLast3]; convert heq₁ using 1 have hβ‚‚ : (tβ‚‚.evalFinBV fun i => bvs'.bvs.get (liftOp (t₁.arity βŠ” tβ‚‚.arity) (Fin.castLE (by omega) i).castSucc)) = bvs'.bvs.get (liftLast3 (t₁.arity βŠ” tβ‚‚.arity) 1) := by simp only [liftOp_unchanged, Fin.castLE_castLE, liftLast3]; convert heqβ‚‚ rcases op with _ | _ | _ <;> . simp [subst, openTerm] at *; congr
4
57
false
Compiler
298
Predicate.eval_eq_denote
theorem Predicate.eval_eq_denote (w : Nat) (p : Predicate) (vars : List (BitVec w)) : (p.eval (vars.map .ofBitVecSext) w = false) ↔ p.denote w vars
lean-mlir
Blase/Blase/Fast/Defs.lean
[ "import Blase.SingleWidth.Defs", "import Mathlib.Data.Fin.Basic", "import Mathlib.Data.Bool.Basic", "import Blase.Fast.BitStream", "import Blase.Blase.Fast.BitStream" ]
[ { "name": "Bool", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Int.xor", "module": "Mathlib.Data.Int.Bitwise" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Nat.testBit", "module": "Init.Data.Nat.Bitwise.Basic" }, { "name": "BitVec", "module": "Init.Prelude" }, { "name": "BitVec.ofNat", "module": "Init.Prelude" }, { "name": "List.map", "module": "Init.Prelude" }, { "name": "BitVec.ult", "module": "Init.Data.BitVec.Basic" }, { "name": "BitVec.carry", "module": "Init.Data.BitVec.Bitblast" }, { "name": "BitVec.sle", "module": "Init.Data.BitVec.Basic" }, { "name": "BitVec.slt", "module": "Init.Data.BitVec.Basic" }, { "name": "BitVec.ule", "module": "Init.Data.BitVec.Basic" }, { "name": "BitVec.adcb", "module": "Init.Data.BitVec.Bitblast" }, { "name": "Prod", "module": "Init.Prelude" } ]
[ { "name": "syntax \"slt\" : MLIR.Pretty.uniform_op", "content": "syntax \"slt\" : MLIR.Pretty.uniform_op" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = const ($x)\n $[: $outer_type]? ) => do\n let outer_type ← outer_type.getDM `(mlir_type| _)\n `(mlir_op| $res:mlir_op_operand = \"const\"()\n {val = $x:num : $outer_type} : ($outer_type) -> ($outer_type) )" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = li ($x)\n $[: $outer_type]? ) => do\n let outer_type ← outer_type.getDM `(mlir_type| _ )\n `(mlir_op| $res:mlir_op_operand = \"li\"()\n {imm = $x:num : $outer_type } : ($outer_type) -> ($outer_type))" }, { "name": "macro_rules", "content": "macro_rules\n| `(mlir_op| $res:mlir_op_operand = $op1:MLIR.Pretty.RV.opWithImmediate $reg1 , $x : $t) => do\n let some opName := MLIR.EDSL.Pretty.extractOpName op1.raw\n | Macro.throwUnsupported\n `(mlir_op| $res:mlir_op_operand = $opName ($reg1) {imm = $x:num : $t} : ($t) -> ($t) )" }, { "name": "macro_rules", "content": "macro_rules\n| `(mlir_op| $res:mlir_op_operand = $op1:MLIR.Pretty.RV.opWithShamt $reg1 , $x : $t ) => do\n let some opName := MLIR.EDSL.Pretty.extractOpName op1.raw\n | Macro.throwUnsupported\n `(mlir_op| $res:mlir_op_operand = $opName ($reg1) {shamt = $x:num : $t} : ($t) -> ($t) )" }, { "name": "BitStream", "content": "def BitStream : Type := Nat β†’ Bool" }, { "name": "borrow", "content": "def borrow (x y : BitStream) : BitStream :=\n fun n => (subAux x y n).2" }, { "name": "subAux", "content": "def subAux (x y : BitStream) : Nat β†’ Bool Γ— Bool\n | 0 => (xor (x 0) (y 0), !(x 0) && y 0)\n | n+1 =>\n let borrow := (subAux x y n).2\n let a := x (n + 1)\n let b := y (n + 1)\n (xor a (xor b borrow), !a && b || ((!(xor a b)) && borrow))" }, { "name": "nxor", "content": "def nxor (a b : BitStream) : BitStream := fun i => a i == b i" }, { "name": "scanAnd", "content": "def scanAnd (s : BitStream) : BitStream := scanl true Bool.and s" }, { "name": "scanl", "content": "abbrev scanl (init : Bool) (f : Bool β†’ Bool β†’ Bool) (s : BitStream) : BitStream :=\n fun n => match n with\n | 0 => f init (s 0)\n | n+1 => f (scanl init f s n) (s (n + 1))" }, { "name": "scanOr", "content": "def scanOr (s : BitStream) : BitStream := scanl false Bool.or s" }, { "name": "falseIffNeq", "content": "abbrev falseIffNeq (n : Nat) : BitStream := fun i => decide (i == n)" }, { "name": "falseIffLt", "content": "abbrev falseIffLt (n : Nat) : BitStream := fun i => decide (i β‰₯ n)" }, { "name": "falseIffGe", "content": "abbrev falseIffGe (n : Nat) : BitStream := fun i => decide (i < n)" }, { "name": "falseIffEq", "content": "abbrev falseIffEq (n : Nat) : BitStream := fun i => decide (i != n)" }, { "name": "falseIffGt", "content": "abbrev falseIffGt (n : Nat) : BitStream := fun i => decide (i ≀ n)" }, { "name": "Term.width", "content": "def Term.width (t : Term) : WidthExpr :=\n match t with\n\n | .ofNat w _n => w\n | .var _v w => w\n | .add w _a _b => w\n | .zext _a wnew => wnew\n | .setWidth _a wnew => wnew\n | .sext _a wnew => wnew\n | .bor w _a _b => w\n | .band w _a _b => w\n | .bxor w _a _b => w\n | .bnot w _a => w\n | .boolVar _v => WidthExpr.const 1 \n | .boolConst _b => WidthExpr.const 1\n | .shiftl w _a _k => w\n | .bvOfBool _b => WidthExpr.const 1\n | binWidthRel _k wa wb => WidthExpr.const 0\n | binRel _k w _a _b => w\n | or _p1 _p2 => WidthExpr.const 0\n | and _p1 _p2 => WidthExpr.const 0\n | pvar _v => WidthExpr.const 0\n | boolBinRel _k _a _b => WidthExpr.const 0" }, { "name": "falseIffLe", "content": "abbrev falseIffLe (n : Nat) : BitStream := fun i => decide (i > n)" }, { "name": "negOne", "content": "abbrev negOne : BitStream := fun _ => true" }, { "name": "shiftLeft", "content": "def shiftLeft (x : BitStream) (k : Nat) : BitStream :=\n fun i => if i < k then false else x (i - k) " }, { "name": "ofNat", "content": "def ofNat (x : Nat) : BitStream :=\n Nat.testBit x" }, { "name": "one", "content": "abbrev one : BitStream := (Β· == 0)" }, { "name": "zero", "content": "abbrev zero : BitStream := fun _ => false" }, { "name": "Predicate", "content": "inductive Predicate : Type where\n \n| width (wp : WidthPredicate) (n : Nat) : Predicate\n| binary (p : BinaryPredicate) (t₁ tβ‚‚ : Term)\n| land (p q : Predicate) : Predicate\n| lor (p q : Predicate) : Predicate\nderiving Repr, Inhabited, Lean.ToExpr" }, { "name": "neg", "content": "def neg (x : BitStream) : BitStream :=\n fun n => (negAux x n).1" }, { "name": "negAux", "content": "def negAux (x : BitStream) : Nat β†’ Bool Γ— Bool\n | 0 => (x 0, !(x 0))\n | n+1 =>\n let borrow := (negAux x n).2\n let a := x (n + 1)\n (xor (!a) borrow, !a && borrow)" }, { "name": "map", "content": "abbrev map (f : Bool β†’ Bool) : BitStream β†’ BitStream :=\n fun x i => f (x i)" }, { "name": "ofBitVecSext", "content": "abbrev ofBitVecSext {w} (x : BitVec w) : BitStream :=\n fun i => if i < w then x.getLsbD i else x.msb" }, { "name": "Term.denote", "content": "def Term.denote (w : Nat) (t : Term) (vars : List (BitVec w)) : BitVec w :=\n match t with\n | ofNat n => BitVec.ofNat w n\n | var n => vars.getD n default\n | zero => 0#w\n | negOne => -1#w\n | one => 1#w\n | and a b => (a.denote w vars) &&& (b.denote w vars)\n | or a b => (a.denote w vars) ||| (b.denote w vars)\n | xor a b => (a.denote w vars) ^^^ (b.denote w vars)\n | not a => ~~~ (a.denote w vars)\n | add a b => (a.denote w vars) + (b.denote w vars)\n | sub a b => (a.denote w vars) - (b.denote w vars)\n | neg a => - (a.denote w vars)\n \n \n | shiftL a n => (a.denote w vars) <<< n" }, { "name": "Predicate.denote", "content": "def Predicate.denote (p : Predicate) (w : Nat) (vars : List (BitVec w)) : Prop :=\n match p with\n | .width .ge k => k ≀ w \n | .width .gt k => k < w \n | .width .le k => w ≀ k\n | .width .lt k => w < k\n | .width .neq k => w β‰  k\n | .width .eq k => w = k\n | .binary .eq t₁ tβ‚‚ => t₁.denote w vars = tβ‚‚.denote w vars\n | .binary .neq t₁ tβ‚‚ => t₁.denote w vars β‰  tβ‚‚.denote w vars\n | .binary .sle t₁ tβ‚‚ => ((t₁.denote w vars).sle (tβ‚‚.denote w vars)) = true\n | .binary .slt t₁ tβ‚‚ => ((t₁.denote w vars).slt (tβ‚‚.denote w vars)) = true\n | .binary .ule t₁ tβ‚‚ => ((t₁.denote w vars).ule (tβ‚‚.denote w vars)) = true\n | .binary .ult t₁ tβ‚‚ => (t₁.denote w vars).ult (tβ‚‚.denote w vars) = true\n | .land p q => p.denote w vars ∧ q.denote w vars\n | .lor p q => p.denote w vars ∨ q.denote w vars" }, { "name": "WidthPredicate", "content": "inductive WidthPredicate\n| eq\n| neq\n| lt\n| le\n| gt\n| ge\nderiving Repr, Inhabited, Lean.ToExpr" }, { "name": "toBitVec", "content": "def toBitVec (w : Nat) (x : BitStream) : BitVec w :=\n match w with\n | 0 => 0#0\n | w+1 => (x.toBitVec w).cons (x w)" }, { "name": "Term", "content": "inductive Term : Type\n| var : Nat β†’ Term\n \n| zero : Term\n \n| negOne : Term\n \n| one : Term\n \n| ofNat (n : Nat) : Term\n \n| and : Term β†’ Term β†’ Term\n \n| or : Term β†’ Term β†’ Term\n \n| xor : Term β†’ Term β†’ Term\n \n| not : Term β†’ Term\n \n| add : Term β†’ Term β†’ Term\n \n| sub : Term β†’ Term β†’ Term\n \n| neg : Term β†’ Term\n\n\n \n| shiftL : Term β†’ Nat β†’ Term\n\n\nderiving Repr, Inhabited, Lean.ToExpr" }, { "name": "concat", "content": "def concat (b : Bool) (x : BitStream) : BitStream\n | 0 => b\n | i+1 => x i" }, { "name": "sub", "content": "def sub (x y : BitStream) : BitStream :=\n fun n => (subAux x y n).1" }, { "name": "add", "content": "def add (x y : BitStream) : BitStream :=\n fun n => (addAux x y n).1" }, { "name": "addAux", "content": "def addAux (x y : BitStream) (i : Nat) : Bool Γ— Bool :=\n let carryIn : Bool := match i with\n | 0 => false\n | i + 1 => (addAux x y i).2\n Prod.swap (BitVec.adcb (x i) (y i) carryIn)" } ]
[ { "name": "BitVec.lt_def", "module": "Init.Data.BitVec.Lemmas" }, { "name": "BitVec.of_length_zero", "module": "Init.Data.BitVec.Lemmas" }, { "name": "BitVec.ult_eq_not_carry", "module": "Init.Data.BitVec.Bitblast" }, { "name": "BitVec.eq_of_getLsbD_eq", "module": "Init.Data.BitVec.Bootstrap" }, { "name": "Bool.not_eq_false", "module": "Init.SimpLemmas" }, { "name": "BitVec.eq_of_toInt_eq", "module": "Init.Data.BitVec.Lemmas" }, { "name": "Bool.false_eq_true", "module": "Init.Data.Bool" }, { "name": "Bool.not_eq_true", "module": "Init.SimpLemmas" }, { "name": "Bool.not_false", "module": "Init.SimpLemmas" }, { "name": "Bool.not_true", "module": "Init.SimpLemmas" }, { "name": "decide_false", "module": "Init.Core" }, { "name": "decide_true", "module": "Init.Core" }, { "name": "true_and", "module": "Init.SimpLemmas" }, { "name": "BitVec.neg_one_eq_allOnes", "module": "Init.Data.BitVec.Lemmas" }, { "name": "Bool.true_and", "module": "Init.SimpLemmas" }, { "name": "BitVec.msb_eq_getLsbD_last", "module": "Init.Data.BitVec.Lemmas" }, { "name": "BitVec.le_def", "module": "Init.Data.BitVec.Lemmas" }, { "name": "BitVec.slt_eq_ult", "module": "Init.Data.BitVec.Lemmas" } ]
[ { "name": "subAux_eq_BitVec_carry", "content": "@[simp] theorem subAux_eq_BitVec_carry (a b : BitStream) (w i : Nat) (hi : i < w) :\n (a.subAux b i).2 = !(BitVec.carry (i + 1) (a.toBitVec w) ((~~~b).toBitVec w) true)" }, { "name": "scanOr_true_iff", "content": "theorem scanOr_true_iff (s : BitStream) (n : Nat)\n : s.scanOr n = true ↔ βˆƒ (i : Nat), (i ≀ n) ∧ s i = true" }, { "name": "scanOr_false_iff", "content": "theorem scanOr_false_iff (s : BitStream) (n : Nat) : s.scanOr n = false ↔ βˆ€ (i : Nat), (hi : i ≀ n) β†’ s i = false" }, { "name": "scanOr_succ", "content": "@[simp]\ntheorem scanOr_succ (s : BitStream) : scanOr s (n+1) = ((s.scanOr n) || s (n + 1))" }, { "name": "scanAnd_true_iff", "content": "theorem scanAnd_true_iff (s : BitStream) (n : Nat) :\n s.scanAnd n = true ↔ βˆ€ (i : Nat), (hi : i ≀ n) β†’ s i = true" }, { "name": "scanAnd_succ", "content": "@[simp] theorem scanAnd_succ (s : BitStream) : scanAnd s (n+1) = ((s.scanAnd n) && s (n + 1))" }, { "name": "scanAnd_false_iff", "content": "theorem scanAnd_false_iff (s : BitStream) (n : Nat)\n : s.scanAnd n = false ↔ βˆƒ (i : Nat), (i ≀ n) ∧ s i = false" }, { "name": "and_eq", "content": "@[simp] theorem and_eq : (x &&& y) i = (x i && y i)" }, { "name": "getLsbD_toBitVec", "content": "@[simp] theorem getLsbD_toBitVec (w : Nat) (x : BitStream) :\n (x.toBitVec w).getLsbD i = ((decide (i < w)) && x i)" }, { "name": "xor_eq", "content": "@[simp] theorem xor_eq : (x ^^^ y) i = (xor (x i) (y i))" } ]
[ { "name": "Term.eval", "content": "def Term.eval (t : Term) (vars : List BitStream) : BitStream :=\n match t with\n | var n => vars.getD n default\n | zero => BitStream.zero\n | one => BitStream.one\n | negOne => BitStream.negOne\n | ofNat n => BitStream.ofNat n\n | and t₁ tβ‚‚ => (t₁.eval vars) &&& (tβ‚‚.eval vars)\n | or t₁ tβ‚‚ => (t₁.eval vars) ||| (tβ‚‚.eval vars)\n | xor t₁ tβ‚‚ => (t₁.eval vars) ^^^ (tβ‚‚.eval vars)\n | not t => ~~~(t.eval vars)\n | add t₁ tβ‚‚ => (Term.eval t₁ vars) + (Term.eval tβ‚‚ vars)\n | sub t₁ tβ‚‚ => (Term.eval t₁ vars) - (Term.eval tβ‚‚ vars)\n | neg t => -(Term.eval t vars)\n\n\n | shiftL t n => BitStream.shiftLeft (Term.eval t vars) n" }, { "name": "Predicate.evalEq", "content": "def Predicate.evalEq (t₁ tβ‚‚ : BitStream) : BitStream := (t₁ ^^^ tβ‚‚).concat false |>.scanOr" }, { "name": "Predicate.evalNeq", "content": "def Predicate.evalNeq (t₁ tβ‚‚ : BitStream) : BitStream := (t₁.nxor tβ‚‚).concat true |>.scanAnd" }, { "name": "Predicate.evalLor", "content": "def Predicate.evalLor (t₁ tβ‚‚ : BitStream) : BitStream := (t₁ &&& tβ‚‚)" }, { "name": "Predicate.evalLand", "content": "def Predicate.evalLand (t₁ tβ‚‚ : BitStream) : BitStream := (t₁ ||| tβ‚‚)" }, { "name": "Predicate.evalUlt", "content": "def Predicate.evalUlt (t₁ tβ‚‚ : BitStream) : BitStream := (~~~ (t₁.borrow tβ‚‚)).concat true" }, { "name": "Predicate.evalMsbEq", "content": "def Predicate.evalMsbEq (t₁ tβ‚‚ : BitStream) : BitStream :=\n (t₁ ^^^ tβ‚‚).concat false" }, { "name": "Predicate.evalSlt", "content": "def Predicate.evalSlt (t₁ tβ‚‚ : BitStream) : BitStream :=\n (((Predicate.evalUlt t₁ tβ‚‚)) ^^^ (Predicate.evalMsbEq t₁ tβ‚‚))" }, { "name": "Predicate.eval", "content": "def Predicate.eval (p : Predicate) (vars : List BitStream) : BitStream :=\n match p with\n | .width .eq n => BitStream.falseIffEq n\n | .width .neq n => BitStream.falseIffNeq n\n | .width .lt n => BitStream.falseIffLt n\n | .width .le n => BitStream.falseIffLe n\n | .width .gt n => BitStream.falseIffGt n\n | .width .ge n => BitStream.falseIffGe n\n | lor p q => Predicate.evalLor (p.eval vars) (q.eval vars)\n | land p q => Predicate.evalLand (p.eval vars) (q.eval vars)\n | binary .eq t₁ tβ‚‚ => Predicate.evalEq (t₁.eval vars) (tβ‚‚.eval vars)\n \n | binary .neq t1 t2 => Predicate.evalNeq (t1.eval vars) (t2.eval vars)\n | binary .ult t₁ tβ‚‚ => Predicate.evalUlt (t₁.eval vars) (tβ‚‚.eval vars)\n | binary .ule t₁ tβ‚‚ =>\n Predicate.evalLor\n (Predicate.evalEq (t₁.eval vars) (tβ‚‚.eval vars))\n (Predicate.evalUlt (t₁.eval vars) (tβ‚‚.eval vars))\n | binary .slt t₁ tβ‚‚ => Predicate.evalSlt (t₁.eval vars) (tβ‚‚.eval vars)\n | binary .sle t₁ tβ‚‚ => Predicate.evalLor\n (Predicate.evalEq (t₁.eval vars) (tβ‚‚.eval vars))\n (Predicate.evalSlt (t₁.eval vars) (tβ‚‚.eval vars))" } ]
[ { "name": "Term.eval_eq_denote", "content": "@[simp] theorem Term.eval_eq_denote (t : Term) (w : Nat) (vars : List (BitVec w)) :\n (t.eval (vars.map BitStream.ofBitVecSext)).toBitVec w = t.denote w vars" }, { "name": "Term.eval_eq_denote_apply", "content": "theorem Term.eval_eq_denote_apply (t : Term) {w : Nat} {vars : List (BitVec w)}\n {i : Nat} (hi : i < w) :\n (t.eval (vars.map BitStream.ofBitVecSext)) i = (t.denote w vars).getLsbD i" }, { "name": "Predicate.evalEq_denote_false_iff", "content": "theorem Predicate.evalEq_denote_false_iff {w : Nat} (a b : Term) (vars : List (BitVec w)) :\n evalEq (a.eval (List.map .ofBitVecSext vars)) (b.eval (List.map .ofBitVecSext vars)) w = false ↔\n Term.denote w a vars = Term.denote w b vars" }, { "name": "Predicate.evalEq_iff_not_evalNeq", "content": "theorem Predicate.evalEq_iff_not_evalNeq (a b : BitStream) :\n βˆ€ (w : Nat), evalEq a b w ↔ Β¬ (evalNeq a b w)" }, { "name": "Predicate.evalNeq_denote", "content": "theorem Predicate.evalNeq_denote {w : Nat} (a b : Term) (vars : List (BitVec w)) :\n evalNeq (a.eval (List.map .ofBitVecSext vars)) (b.eval (List.map .ofBitVecSext vars)) w = false ↔\n Term.denote w a vars β‰  Term.denote w b vars" }, { "name": "Predicate.evalEq_denote_true_iff", "content": "theorem Predicate.evalEq_denote_true_iff {w : Nat} (a b : Term) (vars : List (BitVec w)) :\n evalEq (a.eval (List.map .ofBitVecSext vars)) (b.eval (List.map .ofBitVecSext vars)) w = true ↔\n Term.denote w a vars β‰  Term.denote w b vars" }, { "name": "BitVec.lt_eq_decide_ult", "content": "private theorem BitVec.lt_eq_decide_ult {x y : BitVec w} : (x < y) = decide (x.ult y)" }, { "name": "Predicate.evalUlt_denote_false_iff", "content": "theorem Predicate.evalUlt_denote_false_iff {w : Nat} (a b : Term) (vars : List (BitVec w)) :\n evalUlt (a.eval (List.map .ofBitVecSext vars)) (b.eval (List.map .ofBitVecSext vars)) w = false ↔\n (Term.denote w a vars < Term.denote w b vars)" }, { "name": "Predicate.evalUlt_denote_true_iff", "content": "theorem Predicate.evalUlt_denote_true_iff {w : Nat} (a b : Term) (vars : List (BitVec w)) :\n evalUlt (a.eval (List.map .ofBitVecSext vars)) (b.eval (List.map .ofBitVecSext vars)) w = true ↔\n (Term.denote w b vars) ≀ (Term.denote w a vars)" }, { "name": "evalMsbEq_denote_false_iff", "content": "private theorem evalMsbEq_denote_false_iff {w : Nat} (a b : Term) (vars : List (BitVec w)) :\n Predicate.evalMsbEq (a.eval (List.map .ofBitVecSext vars)) (b.eval (List.map .ofBitVecSext vars)) w = false ↔\n ((Term.denote w a vars).msb = (Term.denote w b vars).msb)" }, { "name": "evalMsbEq_denote_true_iff", "content": "private theorem evalMsbEq_denote_true_iff {w : Nat} (a b : Term) (vars : List (BitVec w)) :\n Predicate.evalMsbEq (a.eval (List.map .ofBitVecSext vars)) (b.eval (List.map .ofBitVecSext vars)) w = true ↔\n ((Term.denote w a vars).msb β‰  (Term.denote w b vars).msb)" }, { "name": "eq_true_iff_of_eq_false_iff", "content": "theorem eq_true_iff_of_eq_false_iff (b : Bool) (rhs : Prop) (h : (b = false) ↔ rhs) :\n (b = true) ↔ Β¬ rhs" }, { "name": "Predicate.evalSlt_denote_false_iff", "content": "private theorem Predicate.evalSlt_denote_false_iff {w : Nat} (a b : Term) (vars : List (BitVec w)) :\n evalSlt (a.eval (List.map .ofBitVecSext vars)) (b.eval (List.map .ofBitVecSext vars)) w = false ↔\n (Term.denote w a vars).slt (Term.denote w b vars)" }, { "name": "Predicate.evalSlt_denote_true_iff", "content": "private theorem Predicate.evalSlt_denote_true_iff {w : Nat} (a b : Term) (vars : List (BitVec w)) :\n evalSlt (a.eval (List.map .ofBitVecSext vars)) (b.eval (List.map .ofBitVecSext vars)) w = true ↔\n Β¬ (Term.denote w a vars).slt (Term.denote w b vars)" }, { "name": "BitVec.ForLean.ule_iff_ult_or_eq'", "content": "private theorem BitVec.ForLean.ule_iff_ult_or_eq' (x y : BitVec w) : (x.ule y) = (decide (x = y ∨ x < y))" }, { "name": "BitVec.sle_iff_slt_or_eq", "content": "private theorem BitVec.sle_iff_slt_or_eq (x y : BitVec w) : x.sle y ↔ (decide (x = y) ∨ x.slt y)" }, { "name": "BitVec.ult_notation_eq_decide_ult", "content": "theorem BitVec.ult_notation_eq_decide_ult (x y : BitVec w) : (x.ult y) = decide (x < y)" } ]
import Mathlib.Data.Bool.Basic import Mathlib.Data.Fin.Basic import Blase.Fast.BitStream import Blase.SingleWidth.Defs open Term open BitStream in def Term.eval (t : Term) (vars : List BitStream) : BitStream := match t with | var n => vars.getD n default | zero => BitStream.zero | one => BitStream.one | negOne => BitStream.negOne | ofNat n => BitStream.ofNat n | and t₁ tβ‚‚ => (t₁.eval vars) &&& (tβ‚‚.eval vars) | or t₁ tβ‚‚ => (t₁.eval vars) ||| (tβ‚‚.eval vars) | xor t₁ tβ‚‚ => (t₁.eval vars) ^^^ (tβ‚‚.eval vars) | not t => ~~~(t.eval vars) | add t₁ tβ‚‚ => (Term.eval t₁ vars) + (Term.eval tβ‚‚ vars) | sub t₁ tβ‚‚ => (Term.eval t₁ vars) - (Term.eval tβ‚‚ vars) | neg t => -(Term.eval t vars) | shiftL t n => BitStream.shiftLeft (Term.eval t vars) n def Predicate.evalEq (t₁ tβ‚‚ : BitStream) : BitStream := (t₁ ^^^ tβ‚‚).concat false |>.scanOr def Predicate.evalNeq (t₁ tβ‚‚ : BitStream) : BitStream := (t₁.nxor tβ‚‚).concat true |>.scanAnd def Predicate.evalLor (t₁ tβ‚‚ : BitStream) : BitStream := (t₁ &&& tβ‚‚) def Predicate.evalLand (t₁ tβ‚‚ : BitStream) : BitStream := (t₁ ||| tβ‚‚) def Predicate.evalUlt (t₁ tβ‚‚ : BitStream) : BitStream := (~~~ (t₁.borrow tβ‚‚)).concat true def Predicate.evalMsbEq (t₁ tβ‚‚ : BitStream) : BitStream := (t₁ ^^^ tβ‚‚).concat false def Predicate.evalSlt (t₁ tβ‚‚ : BitStream) : BitStream := (((Predicate.evalUlt t₁ tβ‚‚)) ^^^ (Predicate.evalMsbEq t₁ tβ‚‚)) open BitStream in def Predicate.eval (p : Predicate) (vars : List BitStream) : BitStream := match p with | .width .eq n => BitStream.falseIffEq n | .width .neq n => BitStream.falseIffNeq n | .width .lt n => BitStream.falseIffLt n | .width .le n => BitStream.falseIffLe n | .width .gt n => BitStream.falseIffGt n | .width .ge n => BitStream.falseIffGe n | lor p q => Predicate.evalLor (p.eval vars) (q.eval vars) | land p q => Predicate.evalLand (p.eval vars) (q.eval vars) | binary .eq t₁ tβ‚‚ => Predicate.evalEq (t₁.eval vars) (tβ‚‚.eval vars) | binary .neq t1 t2 => Predicate.evalNeq (t1.eval vars) (t2.eval vars) | binary .ult t₁ tβ‚‚ => Predicate.evalUlt (t₁.eval vars) (tβ‚‚.eval vars) | binary .ule t₁ tβ‚‚ => Predicate.evalLor (Predicate.evalEq (t₁.eval vars) (tβ‚‚.eval vars)) (Predicate.evalUlt (t₁.eval vars) (tβ‚‚.eval vars)) | binary .slt t₁ tβ‚‚ => Predicate.evalSlt (t₁.eval vars) (tβ‚‚.eval vars) | binary .sle t₁ tβ‚‚ => Predicate.evalLor (Predicate.evalEq (t₁.eval vars) (tβ‚‚.eval vars)) (Predicate.evalSlt (t₁.eval vars) (tβ‚‚.eval vars)) section Predicate end Predicate
theorem Predicate.eval_eq_denote (w : Nat) (p : Predicate) (vars : List (BitVec w)) : (p.eval (vars.map .ofBitVecSext) w = false) ↔ p.denote w vars :=
:= by induction p generalizing vars w case width wp n => cases wp <;> simp [eval, denote] case binary p a b => cases p with | eq => simp [eval, denote]; apply evalEq_denote_false_iff | neq => simp [eval, denote]; apply evalNeq_denote | ult => simp [eval, denote] rw [BitVec.ult_notation_eq_decide_ult] by_cases h: Term.denote w a vars < Term.denote w b vars case pos => simp only [h, decide_true, Bool.not_true]; rw [evalUlt_denote_false_iff]; exact h case neg => simp only [h, decide_false, Bool.not_false]; rw [evalUlt_denote_true_iff]; simpa using h | slt => simp [eval, denote]; by_cases h : (Term.denote w a vars).slt (Term.denote w b vars) Β· rw [h] simp [Predicate.evalSlt_denote_false_iff, h] Β· simp at h rw [h] simp only [Bool.not_false] by_contra h' simp only [Bool.not_eq_true] at h' rw [Predicate.evalSlt_denote_false_iff] at h' simp only [h, Bool.false_eq_true] at h' | ule => simp [eval, denote]; simp only [evalLor, BitStream.and_eq] rw [BitVec.ForLean.ule_iff_ult_or_eq' (Term.denote w a vars) (Term.denote w b vars)] by_cases heq : Term.denote w a vars = Term.denote w b vars Β· rw [heq] simp [evalEq_denote_false_iff a b vars |>.mpr heq] Β· simp [heq] by_cases hlt : Term.denote w a vars < Term.denote w b vars Β· simp [hlt] simp [evalUlt_denote_false_iff a b vars |>.mpr hlt] Β· simp [hlt] have := evalEq_denote_false_iff a b vars |>.not |>.mpr heq simp only [this, true_and] have := evalUlt_denote_false_iff a b vars |>.not |>.mpr hlt simp only [this] | sle => simp [eval, denote] simp only [evalLor, BitStream.and_eq] have h := BitVec.sle_iff_slt_or_eq (Term.denote w a vars) (Term.denote w b vars) |>.eq rcases hSle : (Term.denote w a vars).sle (Term.denote w b vars) Β· simp [hSle] at h ⊒ obtain ⟨h₁, hβ‚‚βŸ© := h simp [evalEq_denote_true_iff .. |>.mpr h₁] rw [evalSlt_denote_true_iff .. |>.mpr] simp [hβ‚‚] Β· simp [hSle] at h ⊒ intros hEq simp [evalEq_denote_true_iff .. |>.mp hEq] at h apply evalSlt_denote_false_iff .. |>.mpr h case land p q hp hq => simp [eval, denote, hp, hq, evalLand] case lor p q hp hq => simp [eval, denote] simp only [evalLor, BitStream.and_eq] constructor Β· intros heval by_cases hp' : p.denote w vars Β· simp [hp'] Β· by_cases hq' : q.denote w vars Β· simp [hq'] Β· have := hp .. |>.not |>.mpr hp' simp [this] at heval have := hq .. |>.not |>.mpr hq' simp [this] at heval Β· intros hdenote rcases hdenote with hp' | hq' Β· have := hp .. |>.mpr hp' simp [this] Β· have := hq .. |>.mpr hq' simp [this]
9
96
false
Compiler
299
eq_true_iff_of_eq_false_iff
theorem eq_true_iff_of_eq_false_iff (b : Bool) (rhs : Prop) (h : (b = false) ↔ rhs) : (b = true) ↔ Β¬ rhs
lean-mlir
Blase/Blase/Fast/Defs.lean
[ "import Blase.SingleWidth.Defs", "import Mathlib.Data.Fin.Basic", "import Blase.Fast.BitStream", "import Mathlib.Data.Bool.Basic" ]
[ { "name": "Bool", "module": "Init.Prelude" } ]
[ { "name": "Term", "content": "inductive Term : Type\n| var : Nat β†’ Term\n \n| zero : Term\n \n| negOne : Term\n \n| one : Term\n \n| ofNat (n : Nat) : Term\n \n| and : Term β†’ Term β†’ Term\n \n| or : Term β†’ Term β†’ Term\n \n| xor : Term β†’ Term β†’ Term\n \n| not : Term β†’ Term\n \n| add : Term β†’ Term β†’ Term\n \n| sub : Term β†’ Term β†’ Term\n \n| neg : Term β†’ Term\n\n\n \n| shiftL : Term β†’ Nat β†’ Term\n\n\nderiving Repr, Inhabited, Lean.ToExpr" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "List.getElem_append_left{Ξ±", "content": "theorem List.getElem_append_left{Ξ± : Type u_1} {l₁ lβ‚‚ : List Ξ±} {i : Nat} (hn : i < l₁.length) :\\n(l₁ ++ lβ‚‚)[i] = l₁[i]" } ]
[]
[]
import Mathlib.Data.Bool.Basic import Mathlib.Data.Fin.Basic import Blase.Fast.BitStream import Blase.SingleWidth.Defs open Term open BitStream in open BitStream in section Predicate end Predicate
theorem eq_true_iff_of_eq_false_iff (b : Bool) (rhs : Prop) (h : (b = false) ↔ rhs) : (b = true) ↔ Β¬ rhs :=
:= by constructor Β· intros h' apply h.not.mp simp [h'] Β· intros h' by_contra hcontra simp at hcontra have := h.mp hcontra exact h' this
1
2
false
Compiler
300
ReflectVerif.BvDecide.KInductionCircuits.FSM.carryWith_congrEnv_envBitstream_set_of_le
theorem FSM.carryWith_congrEnv_envBitstream_set_of_le (fsm : FSM arity) (s0 : fsm.Ξ± β†’ Bool) (env : arity β†’ BitStream) (n : Nat) (v : arity β†’ Bool) (k : Nat) (hk : k ≀ n) : fsm.carryWith s0 (envBitstream_set env n v) k = fsm.carryWith s0 env k
lean-mlir
Blase/Blase/KInduction/KInduction.lean
[ "import Blase.Fast.Defs", "import Blase.Vars", "import Blase.Fast.ForLean", "import Lean.Meta.ForEachExpr", "import Mathlib.Data.Bool.Basic", "import Mathlib.Data.Finset.Defs", "import Blase.Fast.FiniteStateMachine", "import Blase.SingleWidth.Syntax", "import Lean.Meta.Tactic.Simp.BuiltinSimprocs.BitVec", "import Blase.Fast.BitStream", "import Blase.EnvBitstream", "import Blase.Blase.Fast.FiniteStateMachine", "import Mathlib.Data.Finset.Basic", "import Mathlib.Data.Fin.Basic", "import Blase.Fast.Decide", "import Lean", "import Mathlib.Data.Multiset.FinsetOps" ]
[ { "name": "Bool", "module": "Init.Prelude" }, { "name": "Nat", "module": "Init.Prelude" }, { "name": "Vector", "module": "Init.Data.Vector.Basic" }, { "name": "Fin", "module": "Init.Prelude" }, { "name": "String", "module": "Init.Prelude" }, { "name": "Unit", "module": "Init.Prelude" }, { "name": "List", "module": "Init.Prelude" }, { "name": "Field", "module": "Mathlib.Algebra.Field.Defs" }, { "name": "DecidableEq", "module": "Init.Prelude" }, { "name": "FinEnum", "module": "Mathlib.Data.FinEnum" }, { "name": "Hashable", "module": "Init.Prelude" }, { "name": "Empty", "module": "Init.Prelude" }, { "name": "Empty.elim", "module": "Init.Core" }, { "name": "Sum", "module": "Init.Core" }, { "name": "Sum.elim", "module": "Init.Data.Sum.Basic" }, { "name": "ZMod", "module": "Mathlib.Data.ZMod.Defs" } ]
[ { "name": "syntax \"llvm.and\" : MLIR.Pretty.uniform_op", "content": "syntax \"llvm.and\" : MLIR.Pretty.uniform_op\n\nsyntax \"llvm.ashr\" : MLIR.Pretty.exact_op\n\nsyntax \"llvm.add\" : MLIR.Pretty.overflow_op\n\nsyntax \"llvm.return\" : MLIR.Pretty.uniform_op\n\nsyntax \"return\" : MLIR.Pretty.uniform_op" }, { "name": "macro_rules", "content": "macro_rules\n \n | `(mlir_op| $v:mlir_op_operand = mod_arith.constant $x:neg_num : $t) =>\n `(mlir_op| $v:mlir_op_operand = \"mod_arith.constant\" () {value = $x:neg_num} : () -> ($t))\n\n \n | `(mlir_op| $v:mlir_op_operand = mod_arith.constant ${ $x:term } : $t) => do\n let ctor := mkIdent ``MLIR.AST.AttrValue.int\n let x ← `($ctor $x [mlir_type| i64])\n `(mlir_op| $v:mlir_op_operand = \"mod_arith.constant\" () {value = $$($x)} : () -> ($t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $resName:mlir_op_operand = $name:InstCombine.cmp_op_name $x, $y $[: $t]?) => do\n let some opName := extractOpName name.raw\n | Macro.throwUnsupported\n let t ← t.getDM `(mlir_type| _)\n `(mlir_op| $resName:mlir_op_operand = $opName ($x, $y) : ($t, $t) -> (i1) )" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $resName:mlir_op_operand = $name:InstCombine.int_cast_op $x : $t to $t') => do\n let some opName := extractOpName name.raw\n | Macro.throwUnsupported\n `(mlir_op| $resName:mlir_op_operand = $opName ($x) : ($t) -> $t')" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant( $x $[: $inner_type]?)\n $[: $outer_type]? ) => do\n \n let outer_type ← outer_type.getDM `(mlir_type| _)\n let inner_type := inner_type.getD outer_type\n `(mlir_op| $res:mlir_op_operand = \"llvm.mlir.constant\"()\n {value = $x:neg_num : $inner_type} : () -> ($outer_type) )\n | `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant( ${ $x:term }) $[: $t]?) => do\n let t ← t.getDM `(mlir_type| _)\n let x ← `(MLIR.AST.AttrValue.int $x [mlir_type| $t])\n `(mlir_op| $res:mlir_op_operand = \"llvm.mlir.constant\"() {value = $$($x) } : () -> ($t) )" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant (true) $[: $t]?) =>\n `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant (1 : i1) : i1)\n | `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant (false) $[: $t]?) =>\n `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant (0 : i1) : i1)\n | `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant $x $[: $t]?) =>\n `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant($x $[: $t]?) $[: $t]?)\n | `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant ${ $x:term } $[: $t]?) =>\n `(mlir_op| $res:mlir_op_operand = llvm.mlir.constant($$($x) $[: $t]?) $[: $t]?)" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = llvm.icmp $p $x, $y $[: $t]?) => do\n let t ← t.getDM `(mlir_type| _)\n match p.getString with\n | \"eq\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.eq\" ($x, $y) : ($t, $t) -> (i1))\n | \"ne\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.ne\" ($x, $y) : ($t, $t) -> (i1))\n | \"slt\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.slt\" ($x, $y) : ($t, $t) -> (i1))\n | \"sle\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.sle\" ($x, $y) : ($t, $t) -> (i1))\n | \"sgt\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.sgt\" ($x, $y) : ($t, $t) -> (i1))\n | \"sge\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.sge\" ($x, $y) : ($t, $t) -> (i1))\n | \"ult\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.ult\" ($x, $y) : ($t, $t) -> (i1))\n | \"ule\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.ule\" ($x, $y) : ($t, $t) -> (i1))\n | \"ugt\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.ugt\" ($x, $y) : ($t, $t) -> (i1))\n | \"uge\" => `(mlir_op| $res:mlir_op_operand = \"llvm.icmp.uge\" ($x, $y) : ($t, $t) -> (i1))\n | _ => Macro.throwErrorAt p s!\"unexpected predicate {p.getString}\"" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $res:mlir_op_operand = llvm.select $c, $x, $y $[: $t]?) => do\n let t ← t.getDM `(mlir_type| _)\n `(mlir_op| $res:mlir_op_operand = \"llvm.select\" ($c, $x, $y) : (i1, $t, $t) -> ($t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $v:mlir_op_operand = arith.const $x:neg_num : $t) =>\n `(mlir_op| $v:mlir_op_operand = \"arith.const\" () {value = $x:neg_num } : () -> ($t))\n | `(mlir_op| $v:mlir_op_operand = arith.const ${ $x:term } : $t) => do\n let ctor := mkIdent ``MLIR.AST.AttrValue.int\n let x ← `($ctor $x [mlir_type| i64])\n \n \n \n \n `(mlir_op| $v:mlir_op_operand = \"arith.const\" () {value = $$($x) } : () -> ($t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $v:mlir_op_operand = poly.const $x:neg_num : $t) =>\n `(mlir_op| $v:mlir_op_operand = \"poly.const\" () {value = $x:neg_num } : () -> ($t))\n | `(mlir_op| $v:mlir_op_operand = poly.const ${ $x:term } : $t) => do\n let ctor := mkIdent ``MLIR.AST.AttrValue.int\n let x ← `($ctor $x [mlir_type| i64])\n \n \n \n \n `(mlir_op| $v:mlir_op_operand = \"poly.const\" () {value = $$($x) } : () -> ($t))" }, { "name": "macro_rules", "content": "macro_rules\n | `(mlir_op| $v:mlir_op_operand = poly.monomial $xs,* : ($ts,*) -> $t) =>\n `(mlir_op| $v:mlir_op_operand = \"poly.monomial\" ($xs,*) : ($ts,*) -> $t)" }, { "name": "BitStream", "content": "def BitStream : Type := Nat β†’ Bool" }, { "name": "FSM", "content": "structure FSM (arity : Type) : Type 1 where\n \n ( Ξ± : Type )\n [ i : FinEnum Ξ± ]\n [ h : Hashable Ξ± ]\n [ dec_eq : DecidableEq Ξ± ]\n \n ( initCarry : Ξ± β†’ Bool )\n \n outputCirc : Circuit (Ξ± βŠ• arity)\n nextStateCirc : Ξ± β†’ Circuit (Ξ± βŠ• arity)" }, { "name": "Circuit", "content": "inductive Circuit (Ξ± : Type u) : Type u\n | tru : Circuit Ξ±\n | fals : Circuit Ξ±\n \n | var : (positive: Bool) β†’ Ξ± β†’ Circuit Ξ±\n | and : Circuit Ξ± β†’ Circuit Ξ± β†’ Circuit Ξ±\n | or : Circuit Ξ± β†’ Circuit Ξ± β†’ Circuit Ξ±\n | xor : Circuit Ξ± β†’ Circuit Ξ± β†’ Circuit Ξ±\nderiving Repr, DecidableEq" }, { "name": "Var", "content": "def Var (Ξ“ : Context Ty) (ty : Ty) : Type := { v : VarName // Ξ“.hasType v ty }" }, { "name": "carryWith", "content": "def carryWith (p : FSM arity) (carryState : p.Ξ± β†’ Bool) (x : arity β†’ BitStream) (n : Nat) : p.Ξ± β†’ Bool := fun a =>\n (p.changeInitCarry carryState).carry x n a" }, { "name": "changeInitCarry", "content": "def changeInitCarry (p : FSM arity) (c : p.Ξ± β†’ Bool) : FSM arity :=\n { p with initCarry := c }" }, { "name": "zero", "content": "def zero : FSM (Fin 0) :=\n { Ξ± := Empty,\n initCarry := Empty.elim,\n nextStateCirc := Empty.elim,\n outputCirc := Circuit.fals\n }" }, { "name": "carry", "content": "def carry (x : arity β†’ BitStream) : β„• β†’ p.State\n | 0 => p.initCarry\n | n+1 => (p.nextBit (carry x n) (fun i => x i n)).1" }, { "name": "State", "content": "abbrev State : Type := p.Ξ± β†’ Bool" }, { "name": "nextBit", "content": "def nextBit : p.State β†’ (arity β†’ Bool) β†’ p.State Γ— Bool :=\n fun carry inputBits =>\n let input := Sum.elim carry inputBits\n let newState : p.State := fun (a : p.Ξ±) => (p.nextStateCirc a).eval input\n let outBit : Bool := (p.outputCirc).eval input\n (newState, outBit)" }, { "name": "rhs", "content": "def rhs := [poly q, n, hq | {\n^bb0(%a : !R):\n return %a : !R\n\n}]" }, { "name": "AttrValue", "content": "inductive AttrValue where\n | symbol: String -> AttrValue \n | str : String -> AttrValue\n | int : Int -> MLIRType Ο† -> AttrValue\n | nat: Nat -> AttrValue\n | bool : Bool -> AttrValue\n | float : Float -> MLIRType Ο† -> AttrValue\n | type : MLIRType Ο† -> AttrValue\n | affine: AffineMap -> AttrValue\n | permutation: List Nat -> AttrValue \n | list: List AttrValue -> AttrValue\n | nestedsymbol: AttrValue -> AttrValue -> AttrValue\n | alias: String -> AttrValue\n | dict: AttrDict -> AttrValue\n | opaque_: (dialect: String) -> (value: String) -> AttrValue\n | opaqueElements: (dialect: String) -> (value: String) -> (type: MLIRType Ο†) -> AttrValue\n | unit: AttrValue" }, { "name": "R", "content": "abbrev R := (ZMod q)[X] β§Έ (Ideal.span {f q n})" }, { "name": "bb0", "content": "def bb0 : Region 0 := [mlir_region|\n{\n ^bb0(%arg0: i32):\n %0 = llvm.mlir.constant(8) : i32\n %1 = llvm.mlir.constant(31) : i32\n %2 = llvm.ashr %arg0, %1 : i32\n %3 = llvm.and %2, %0 : i32\n %4 = llvm.add %3, %2 : i32\n llvm.return %4 : i32\n }]" }, { "name": "Region", "content": "structure Region where\n (name: String)\n (args: List <| TypedSSAVal Ο†)\n (ops: List Op)" } ]
[ { "name": "...", "module": "" } ]
[ { "name": "carryWith_congrEnv", "content": "theorem carryWith_congrEnv {p : FSM arity}\n {carryState : p.Ξ± β†’ Bool} {x y : arity β†’ BitStream} {n : Nat}\n (h : βˆ€ a i, i < n β†’ x a i = y a i) :\n p.carryWith carryState x n = p.carryWith carryState y n" }, { "name": "carry_congrEnv", "content": "theorem carry_congrEnv {p : FSM arity}\n {x y : arity β†’ BitStream} {n : Nat} (h : βˆ€ a i, i < n β†’ x a i = y a i) :\n p.carry x n = p.carry y n" } ]
[ { "name": "ReflectVerif.BvDecide.KInductionCircuits", "content": "structure KInductionCircuits {arity : Type _}\n [DecidableEq arity] [Fintype arity] [Hashable arity] (fsm : FSM arity) (n : Nat) where\n \n cInitCarryAssignCirc : Circuit (Vars fsm.Ξ± arity 0)\n \n cSuccCarryAssignCirc : Circuit (Vars fsm.Ξ± arity (n+2))\n \n cOutAssignCirc : Circuit (Vars fsm.Ξ± arity (n + 2))\n \n cStatesUniqueCirc : Circuit (Vars fsm.Ξ± arity n)" }, { "name": "ReflectVerif.BvDecide.KInductionCircuits.envBitstream_set", "content": "def envBitstream_set (x : arity β†’ BitStream) (n : Nat) (v : arity β†’ Bool) :\n arity β†’ BitStream :=\n fun a j => if j = n then v a else x a j" } ]
[]
import Mathlib.Data.Bool.Basic import Mathlib.Data.Fin.Basic import Mathlib.Data.Finset.Basic import Mathlib.Data.Finset.Defs import Mathlib.Data.Multiset.FinsetOps import Blase.Fast.BitStream import Blase.Fast.Defs import Blase.Fast.FiniteStateMachine import Blase.Fast.Decide import Blase.SingleWidth.Syntax import Lean.Meta.ForEachExpr import Lean.Meta.Tactic.Simp.BuiltinSimprocs.BitVec import Blase.Fast.ForLean import Blase.Vars import Blase.EnvBitstream import Lean open Fin.NatCast namespace ReflectVerif open Lean Meta Elab Tactic namespace BvDecide open Std Sat AIG structure KInductionCircuits {arity : Type _} [DecidableEq arity] [Fintype arity] [Hashable arity] (fsm : FSM arity) (n : Nat) where cInitCarryAssignCirc : Circuit (Vars fsm.Ξ± arity 0) cSuccCarryAssignCirc : Circuit (Vars fsm.Ξ± arity (n+2)) cOutAssignCirc : Circuit (Vars fsm.Ξ± arity (n + 2)) cStatesUniqueCirc : Circuit (Vars fsm.Ξ± arity n) namespace KInductionCircuits variable {arity : Type _} {fsm : FSM arity} variable [DecidableEq arity] [Fintype arity] [Hashable arity] def envBitstream_set (x : arity β†’ BitStream) (n : Nat) (v : arity β†’ Bool) : arity β†’ BitStream := fun a j => if j = n then v a else x a j
theorem FSM.carryWith_congrEnv_envBitstream_set_of_le (fsm : FSM arity) (s0 : fsm.Ξ± β†’ Bool) (env : arity β†’ BitStream) (n : Nat) (v : arity β†’ Bool) (k : Nat) (hk : k ≀ n) : fsm.carryWith s0 (envBitstream_set env n v) k = fsm.carryWith s0 env k :=
:= by apply FSM.carryWith_congrEnv intros a l hl simp [envBitstream_set] intros hcontra; omega
5
33
false
Compiler