chars
int64
40
24k
content_type
stringclasses
9 values
id
stringlengths
13
64
source
stringclasses
5 values
subset
stringclasses
31 values
text
stringlengths
40
24k
173
leanexplore_declaration
leanexplore:387625
leanexplore_sqlite
leanexplore_declarations
/-- Trace equivalence is symmetric. -/ theorem TraceEq.symm (h : s₁ ~tr[lts₁,lts₂] s₂) : s₂ ~tr[lts₂,lts₁] s₁ := by simp only [TraceEq] at h simp only [TraceEq] rw [h]
191
leanexplore_declaration
leanexplore:387626
leanexplore_sqlite
leanexplore_declarations
/-- Trace equivalence is transitive. -/ theorem TraceEq.trans (h1 : s₁ ~tr[lts₁,lts₂] s₂) (h2 : s₂ ~tr[lts₂,lts₃] s₃) : s₁ ~tr[lts₁,lts₃] s₃ := by simp only [TraceEq] at * rw [h1, h2]
196
leanexplore_declaration
leanexplore:387627
leanexplore_sqlite
leanexplore_declarations
/-- Homogeneous trace equivalence is an equivalence relation. -/ theorem HomTraceEq.eqv : Equivalence (· ~tr[lts] ·) where refl := HomTraceEq.refl symm := TraceEq.symm trans := TraceEq.trans
157
leanexplore_declaration
leanexplore:387628
leanexplore_sqlite
leanexplore_declarations
/-- `calc` support for simulation equivalence. -/ instance : Trans (TraceEq lts₁ lts₂) (TraceEq lts₂ lts₃) (TraceEq lts₁ lts₃) where trans := TraceEq.trans
1,510
leanexplore_declaration
leanexplore:387629
leanexplore_sqlite
leanexplore_declarations
/-- In deterministic LTSs, trace equivalence is a simulation. -/ theorem TraceEq.deterministic_isSimulation {lts₁ : LTS State₁ Label} {lts₂ : LTS State₂ Label} [hdet₁ : lts₁.Deterministic] [hdet₂ : lts₂.Deterministic] : IsSimulation lts₁ lts₂ (TraceEq lts₁ lts₂) := by intro s₁ s₂ h μ s₁' htr1 have hmtr1 := ...
145
leanexplore_declaration
leanexplore:387630
leanexplore_sqlite
leanexplore_declarations
/-- The union of two LTSs defined on the same types. -/ def union (lts1 lts2 : LTS State Label) : LTS State Label where Tr := lts1.Tr ⊔ lts2.Tr
596
leanexplore_declaration
leanexplore:387631
leanexplore_sqlite
leanexplore_declarations
/-- The union of two LTSs that have common supertypes for states and labels. -/ def unionSubtype {S1 : State → Prop} {L1 : Label → Prop} {S2 : State → Prop} {L2 : Label → Prop} [DecidablePred S1] [DecidablePred L1] [DecidablePred S2] [DecidablePred L2] (lts1 : LTS (@Subtype State S1) (@Subtype Label L1)) (lts2 : LTS (@...
288
leanexplore_declaration
leanexplore:387632
leanexplore_sqlite
leanexplore_declarations
/-- Lifting of an `LTS State Label` to `LTS (State ⊕ State') Label`. -/ def inl (lts : LTS State Label) : LTS { x : State ⊕ State' // x.isLeft } { _label : Label // True } where Tr s μ s' := match s, s' with | ⟨.inl s1, _⟩, ⟨.inl s2, _⟩ => lts.Tr s1 μ s2 | _, _ => False
289
leanexplore_declaration
leanexplore:387633
leanexplore_sqlite
leanexplore_declarations
/-- Lifting of an `LTS State Label` to `LTS (State' ⊕ State) Label`. -/ def inr (lts : LTS State Label) : LTS { x : State' ⊕ State // x.isRight } { _label : Label // True } where Tr s μ s' := match s, s' with | ⟨.inr s1, _⟩, ⟨.inr s2, _⟩ => lts.Tr s1 μ s2 | _, _ => False
291
leanexplore_declaration
leanexplore:387634
leanexplore_sqlite
leanexplore_declarations
/-- Union of two LTSs with the same `Label` type. The result combines the original respective state types `State1` and `State2` into `(State1 ⊕ State2)`. -/ def unionSum (lts1 : LTS State1 Label) (lts2 : LTS State2 Label) : LTS (State1 ⊕ State2) Label := unionSubtype lts1.inl lts2.inr
218
leanexplore_declaration
leanexplore:387635
leanexplore_sqlite
leanexplore_declarations
/-- An equivalence relation on `α` preserved by all contexts `Ctx`. -/ class Congruence (α : Type*) [HasContext α] (r : α → α → Prop) extends IsEquiv α r, covariant : CovariantClass (HasContext.Context α) α (·<[·]) r
287
leanexplore_declaration
leanexplore:387636
leanexplore_sqlite
leanexplore_declarations
/-- Class for types with a canonical notion of heterogeneous single-hole contexts. -/ class HasHContext (α β : Type*) where /-- The type of contexts. -/ Context : Type* /-- Replaces the hole in the context with a value, resulting in a new value. -/ fill (c : Context) (b : β) : α
221
leanexplore_declaration
leanexplore:387637
leanexplore_sqlite
leanexplore_declarations
@[inherit_doc] notation:max c "<[" t "]" => HasHContext.fill c t /-- Class for types (`α`) that have a canonical notion of homogeneous single-hole contexts (`Context`). -/ abbrev HasContext (α : Type*) := HasHContext α α
155
leanexplore_declaration
leanexplore:387638
leanexplore_sqlite
leanexplore_declarations
/-- Class for types (`α`) that have a canonical notion of homogeneous single-hole contexts (`Context`). -/ abbrev HasContext (α : Type*) := HasHContext α α
119
leanexplore_declaration
leanexplore:387639
leanexplore_sqlite
leanexplore_declarations
@[inherit_doc HasHContext.Context] def HasContext.Context (α : Type*) [HasContext α] : Type* := HasHContext.Context α α
168
leanexplore_declaration
leanexplore:387640
leanexplore_sqlite
leanexplore_declarations
/-- Typeclass for the α-equivalence notation `x =α y`. -/ class HasAlphaEquiv (β : Type u) where /-- α-equivalence relation for type β. -/ AlphaEquiv : β → β → Prop
85
leanexplore_declaration
leanexplore:387641
leanexplore_sqlite
leanexplore_declarations
@[inherit_doc] notation m:max " =α " n:max => HasAlphaEquiv.AlphaEquiv m n end Cslib
240
leanexplore_declaration
leanexplore:387642
leanexplore_sqlite
leanexplore_declarations
/-- Typeclass for substitution relations and access to their notation. -/ class HasSubstitution (α : Type u) (β : Type v) (γ : Type w) where /-- Substitution function. Replaces `x` in `t` with `t'`. -/ subst (t : α) (x : β) (t' : γ) : α
98
leanexplore_declaration
leanexplore:387643
leanexplore_sqlite
leanexplore_declarations
/-- Notation for substitution. -/ notation t:max "[" x ":=" t' "]" => HasSubstitution.subst t x t'
177
leanexplore_declaration
leanexplore:387644
leanexplore_sqlite
leanexplore_declarations
/-- Typeclass for types equipped with a well-formedness predicate. -/ class HasWellFormed (α : Type u) where /-- Establishes whether `x` is well-formed. -/ wf (x : α) : Prop
77
leanexplore_declaration
leanexplore:387645
leanexplore_sqlite
leanexplore_declarations
/-- Notation for well-formedness. -/ notation x:max "✓" => HasWellFormed.wf x
129
leanexplore_declaration
leanexplore:387646
leanexplore_sqlite
leanexplore_declarations
/-- Actions. -/ inductive Act (Name : Type u) : Type u where | name (a : Name) | coname (a : Name) | τ deriving DecidableEq
325
leanexplore_declaration
leanexplore:387652
leanexplore_sqlite
leanexplore_declarations
/-- Processes. -/ inductive Process (Name : Type u) (Constant : Type v) : Type (max u v) where | nil | pre (μ : Act Name) (p : Process Name Constant) | par (p q : Process Name Constant) | choice (p q : Process Name Constant) | res (a : Name) (p : Process Name Constant) | const (c : Constant) deriving Decida...
48
leanexplore_declaration
leanexplore:387654
leanexplore_sqlite
leanexplore_declarations
| pre (μ : Act Name) (p : Process Name Constant)
44
leanexplore_declaration
leanexplore:387657
leanexplore_sqlite
leanexplore_declarations
| res (a : Name) (p : Process Name Constant)
185
leanexplore_declaration
leanexplore:387661
leanexplore_sqlite
leanexplore_declarations
/-- An action is visible if it a name or a coname. -/ @[scoped grind] inductive IsVisible : Act Name → Prop where | name : IsVisible (Act.name a) | coname : IsVisible (Act.coname a)
165
leanexplore_declaration
leanexplore:387664
leanexplore_sqlite
leanexplore_declarations
/-- If an action is visible, it is not `τ`. -/ @[scoped grind →, simp] theorem isVisible_neq_τ {μ : Act Name} (h : μ.IsVisible) : μ ≠ Act.τ := by cases μ <;> grind
200
leanexplore_declaration
leanexplore:387665
leanexplore_sqlite
leanexplore_declarations
/-- Checks that an action is the coaction of another. -/ @[scoped grind] inductive Co {Name : Type u} : Act Name → Act Name → Prop where | nc : Co (name a) (coname a) | cn : Co (coname a) (name a)
113
leanexplore_declaration
leanexplore:387668
leanexplore_sqlite
leanexplore_declarations
/-- `Act.Co` is symmetric. -/ @[scoped grind →, symm] theorem Co.symm (h : Act.Co μ μ') : Act.Co μ' μ := by grind
182
leanexplore_declaration
leanexplore:387669
leanexplore_sqlite
leanexplore_declarations
/-- If two actions are one the coaction of the other, then they are both visible. -/ @[scoped grind →] theorem co_isVisible (h : Act.Co μ μ') : μ.IsVisible ∧ μ'.IsVisible := by grind
257
leanexplore_declaration
leanexplore:387670
leanexplore_sqlite
leanexplore_declarations
/-- Checks that an action is the coaction of another. This is the Boolean version of `Act.Co`. -/ @[scoped grind =] def isCo [DecidableEq Name] (μ μ' : Act Name) : Bool := match μ, μ' with | name a, coname b | coname a, name b => a = b | _, _ => false
101
leanexplore_declaration
leanexplore:387671
leanexplore_sqlite
leanexplore_declarations
theorem isCo_iff [DecidableEq Name] {μ μ' : Act Name} : isCo μ μ' ↔ Co μ μ' := by grind [cases Act]
173
leanexplore_declaration
leanexplore:387672
leanexplore_sqlite
leanexplore_declarations
/-- `Act.Co` is decidable if `Name` equality is decidable. -/ instance [DecidableEq Name] {μ μ' : Act Name} : Decidable (Co μ μ') := decidable_of_decidable_of_iff isCo_iff
503
leanexplore_declaration
leanexplore:387673
leanexplore_sqlite
leanexplore_declarations
/-- Contexts. -/ @[scoped grind] inductive Context (Name : Type u) (Constant : Type v) : Type (max u v) where | hole | pre (μ : Act Name) (c : Context Name Constant) | parL (c : Context Name Constant) (q : Process Name Constant) | parR (p : Process Name Constant) (c : Context Name Constant) | choiceL (c : Con...
48
leanexplore_declaration
leanexplore:387675
leanexplore_sqlite
leanexplore_declarations
| pre (μ : Act Name) (c : Context Name Constant)
62
leanexplore_declaration
leanexplore:387676
leanexplore_sqlite
leanexplore_declarations
| parL (c : Context Name Constant) (q : Process Name Constant)
62
leanexplore_declaration
leanexplore:387677
leanexplore_sqlite
leanexplore_declarations
| parR (p : Process Name Constant) (c : Context Name Constant)
65
leanexplore_declaration
leanexplore:387678
leanexplore_sqlite
leanexplore_declarations
| choiceL (c : Context Name Constant) (q : Process Name Constant)
65
leanexplore_declaration
leanexplore:387679
leanexplore_sqlite
leanexplore_declarations
| choiceR (p : Process Name Constant) (c : Context Name Constant)
44
leanexplore_declaration
leanexplore:387680
leanexplore_sqlite
leanexplore_declarations
| res (a : Name) (c : Context Name Constant)
460
leanexplore_declaration
leanexplore:387683
leanexplore_sqlite
leanexplore_declarations
/-- Replaces the hole in a `Context` with a `Process`. -/ @[scoped grind =] def Context.fill (c : Context Name Constant) (p : Process Name Constant) : Process Name Constant := match c with | hole => p | pre μ c => Process.pre μ (c.fill p) | parL c r => Process.par (c.fill p) r | parR r c => Process.par r (c.f...
86
leanexplore_declaration
leanexplore:387684
leanexplore_sqlite
leanexplore_declarations
instance : HasContext (Process Name Constant) := ⟨Context Name Constant, Context.fill⟩
164
leanexplore_declaration
leanexplore:387685
leanexplore_sqlite
leanexplore_declarations
/-- Definition of context filling. -/ @[scoped grind =] theorem context_fill_def (c : Context Name Constant) (p : Process Name Constant) : c<[p] = c.fill p := rfl
795
leanexplore_declaration
leanexplore:387686
leanexplore_sqlite
leanexplore_declarations
/-- Any `Process` can be obtained by filling a `Context` with an atom. This proves that `Context` is a complete formalisation of syntactic contexts for CCS. -/ theorem Context.complete (p : Process Name Constant) : ∃ c : Context Name Constant, p = c<[(Process.nil : Process Name Constant)] ∨ ∃ k : Constant, p = ...
274
leanexplore_declaration
leanexplore:387687
leanexplore_sqlite
leanexplore_declarations
/-- P | 𝟎 ~ P -/ @[simp, scoped grind .] theorem bisimilarity_par_nil : (par p nil) ~[lts (defs := defs)] p := by unfold lts at * exists ParNil, .parNil intro _ _ _ _ constructor case left => grind case right => intro s2' htr exists par s2' nil grind
349
leanexplore_declaration
leanexplore:387688
leanexplore_sqlite
leanexplore_declarations
/-- P | Q ~ Q | P -/ @[scoped grind .] theorem bisimilarity_par_comm : (par p q) ~[lts (defs := defs)] (par q p) := by let defParComm : Process Name Constant → Process Name Constant | par p q => par q p | _ => nil use ParComm, ParComm.parComm intro _ _ _ _ unfold lts at * split_ands <;> intro p _ <;> ...
220
leanexplore_declaration
leanexplore:387689
leanexplore_sqlite
leanexplore_declarations
/-- 𝟎 | P ~ P -/ @[simp, scoped grind .] theorem bisimilarity_nil_par : (par nil p) ~[lts (defs := defs)] p := calc (par nil p) ~[lts (defs := defs)] (par p nil) := by grind _ ~[lts (defs := defs)] p := by simp
1,530
leanexplore_declaration
leanexplore:387690
leanexplore_sqlite
leanexplore_declarations
/-- P | (Q | R) ~ (P | Q) | R -/ theorem bisimilarity_par_assoc : (par p (par q r)) ~[lts (defs := defs)] (par (par p q) r) := by use ParAssoc, ParAssoc.assoc intro s1 s2 hr μ apply And.intro <;> cases hr case right.assoc => intro s2' htr unfold lts at * cases htr case parL p q r p' htr => ...
396
leanexplore_declaration
leanexplore:387691
leanexplore_sqlite
leanexplore_declarations
/-- P + 𝟎 ~ P -/ theorem bisimilarity_choice_nil : (choice p nil) ~[lts (defs := defs)] p := by use ChoiceNil, ChoiceNil.nil intro s1 s2 hr μ apply And.intro <;> cases hr case left.nil => unfold lts grind [ChoiceNil] case right.nil => intro s2' htr exists s2' constructor · apply Tr.ch...
334
leanexplore_declaration
leanexplore:387692
leanexplore_sqlite
leanexplore_declarations
/-- P + P ~ P -/ theorem bisimilarity_choice_idem : (choice p p) ~[lts (defs := defs)] p := by exists ChoiceIdem apply And.intro case left => grind case right => intro s1 s2 hr μ apply And.intro <;> cases hr <;> unfold lts case right.idem => intro s1' htr exists s1' grind a...
621
leanexplore_declaration
leanexplore:387693
leanexplore_sqlite
leanexplore_declarations
/-- P + Q ~ Q + P -/ theorem bisimilarity_choice_comm : (choice p q) ~[lts (defs := defs)] (choice q p) := by exists @ChoiceComm Name Constant defs repeat constructor intro s1 s2 hr μ cases hr case choiceComm p q => constructor case left => intro s1' htr exists s1' constructor ...
933
leanexplore_declaration
leanexplore:387694
leanexplore_sqlite
leanexplore_declarations
/-- P + (Q + R) ~ (P + Q) + R -/ theorem bisimilarity_choice_assoc : (choice p (choice q r)) ~[lts (defs := defs)] (choice (choice p q) r) := by use ChoiceAssoc, ChoiceAssoc.assoc intro s1 s2 hr μ apply And.intro <;> cases hr case left.assoc p q r => intro s htr refine ⟨s, ?_, ChoiceAssoc.id⟩ ca...
401
leanexplore_declaration
leanexplore:387695
leanexplore_sqlite
leanexplore_declarations
/-- P ~ Q → μ.P ~ μ.Q -/ theorem bisimilarity_congr_pre : (p ~[lts (defs := defs)] q) → (pre μ p) ~[lts (defs := defs)] (pre μ q) := by intro hpq exists @PreBisim _ _ defs constructor · grind intro s1 s2 hr μ' cases hr case pre p' q' μ hbis => unfold lts constructor <;> intro _ _ <;> [exists q...
984
leanexplore_declaration
leanexplore:387696
leanexplore_sqlite
leanexplore_declarations
/-- P ~ Q → (ν a) P ~ (ν a) Q -/ theorem bisimilarity_congr_res : (p ~[lts (defs := defs)] q) → (res a p) ~[lts (defs := defs)] (res a q) := by intro hpq exists @ResBisim _ _ defs constructor · grind intro s1 s2 hr μ' cases hr rename_i p q a h constructor case left => intro s1' htr cases h...
1,812
leanexplore_declaration
leanexplore:387697
leanexplore_sqlite
leanexplore_declarations
/-- P ~ Q → P + R ~ Q + R -/ theorem bisimilarity_congr_choice : (p ~[lts (defs := defs)] q) → (choice p r) ~[lts (defs := defs)] (choice q r) := by intro h exists @ChoiceBisim _ _ defs constructor · constructor; assumption intro s1 s2 r μ constructor case left => intro s1' htr cases r cas...
1,258
leanexplore_declaration
leanexplore:387698
leanexplore_sqlite
leanexplore_declarations
/-- P ~ Q → P | R ~ Q | R -/ theorem bisimilarity_congr_par : (p ~[lts (defs := defs)] q) → (par p r) ~[lts (defs := defs)] (par q r) := by intro h exists @ParBisim _ _ defs constructor · grind intro s1 s2 r μ constructor case left => intro s1' htr cases r unfold lts at * have : {Tr :=...
929
leanexplore_declaration
leanexplore:387699
leanexplore_sqlite
leanexplore_declarations
/-- Bisimilarity is a congruence in CCS. -/ theorem bisimilarity_is_congruence (p q : Process Name Constant) (c : Context Name Constant) (h : p ~[lts (defs := defs)] q) : (c.fill p) ~[lts (defs := defs)] (c.fill q) := by induction c with | parR r c _ => calc _ ~[lts (defs := defs)] (c.fill p |>.pa...
227
leanexplore_declaration
leanexplore:387700
leanexplore_sqlite
leanexplore_declarations
/-- Bisimilarity is a congruence in CCS. -/ instance bisimilarityCongruence : Congruence (Process Name Constant) (HomBisimilarity (lts (defs := defs))) where covariant := ⟨by grind [Covariant, bisimilarity_is_congruence]⟩
639
leanexplore_declaration
leanexplore:387701
leanexplore_sqlite
leanexplore_declarations
/-- The transition relation for CCS. This is a direct formalisation of the one found in [Sangiorgi2011]. -/ @[lts lts] inductive Tr : Process Name Constant → Act Name → Process Name Constant → Prop where | pre : Tr (pre μ p) μ p | parL : Tr p μ p' → Tr (par p q) μ (par p' q) | parR : Tr q μ q' → Tr (par p q) μ (p...
46
leanexplore_declaration
leanexplore:387703
leanexplore_sqlite
leanexplore_declarations
| parL : Tr p μ p' → Tr (par p q) μ (par p' q)
46
leanexplore_declaration
leanexplore:387704
leanexplore_sqlite
leanexplore_declarations
| parR : Tr q μ q' → Tr (par p q) μ (par p q')
77
leanexplore_declaration
leanexplore:387705
leanexplore_sqlite
leanexplore_declarations
| com : μ.Co μ' → Tr p μ p' → Tr q μ' q' → Tr (par p q) Act.τ (par p' q')
44
leanexplore_declaration
leanexplore:387706
leanexplore_sqlite
leanexplore_declarations
| choiceL : Tr p μ p' → Tr (choice p q) μ p'
44
leanexplore_declaration
leanexplore:387707
leanexplore_sqlite
leanexplore_declarations
| choiceR : Tr q μ q' → Tr (choice p q) μ q'
81
leanexplore_declaration
leanexplore:387708
leanexplore_sqlite
leanexplore_declarations
| res : μ ≠ Act.name a → μ ≠ Act.coname a → Tr p μ p' → Tr (res a p) μ (res a p')
50
leanexplore_declaration
leanexplore:387709
leanexplore_sqlite
leanexplore_declarations
| const : defs k p → Tr p μ p' → Tr (const k) μ p'
580
leanexplore_declaration
leanexplore:387710
leanexplore_sqlite
leanexplore_declarations
@[lts lts] inductive Tr : Process Name Constant → Act Name → Process Name Constant → Prop where | pre : Tr (pre μ p) μ p | parL : Tr p μ p' → Tr (par p q) μ (par p' q) | parR : Tr q μ q' → Tr (par p q) μ (par p q') | com : μ.Co μ' → Tr p μ p' → Tr q μ' q' → Tr (par p q) Act.τ (par p' q') | choiceL : Tr p ...
47
leanexplore_declaration
leanexplore:387713
leanexplore_sqlite
leanexplore_declarations
instance : HasTau (Act Name) where τ := Act.τ
344
leanexplore_declaration
leanexplore:387714
leanexplore_sqlite
leanexplore_declarations
/-- A process is (successfully) terminated if it is a composition of `nil`s. -/ inductive Terminated : Process Name Constant → Prop where | nil : Terminated Process.nil | par : Terminated p → Terminated q → Terminated (par p q) | choice : Terminated p → Terminated q → Terminated (choice p q) | res : Terminated ...
58
leanexplore_declaration
leanexplore:387716
leanexplore_sqlite
leanexplore_declarations
| par : Terminated p → Terminated q → Terminated (par p q)
64
leanexplore_declaration
leanexplore:387717
leanexplore_sqlite
leanexplore_declarations
| choice : Terminated p → Terminated q → Terminated (choice p q)
43
leanexplore_declaration
leanexplore:387718
leanexplore_sqlite
leanexplore_declarations
| res : Terminated p → Terminated (res a p)
244
leanexplore_declaration
leanexplore:387719
leanexplore_sqlite
leanexplore_declarations
/-- A polynomial is an SKI terms with free variables. -/ protected inductive Polynomial (n : Nat) : Type where | term : SKI → SKI.Polynomial n | var : Fin n → SKI.Polynomial n | app : SKI.Polynomial n → SKI.Polynomial n → SKI.Polynomial n
62
leanexplore_declaration
leanexplore:387722
leanexplore_sqlite
leanexplore_declarations
| app : SKI.Polynomial n → SKI.Polynomial n → SKI.Polynomial n
85
leanexplore_declaration
leanexplore:387723
leanexplore_sqlite
leanexplore_declarations
/-- Application between polynomials -/ scoped infixl:100 " ⬝' " => SKI.Polynomial.app
89
leanexplore_declaration
leanexplore:387724
leanexplore_sqlite
leanexplore_declarations
/-- Notation by analogy with pointers in C -/ scoped prefix:101 "&" => SKI.Polynomial.var
90
leanexplore_declaration
leanexplore:387725
leanexplore_sqlite
leanexplore_declarations
instance CoeTermPolynomial (n : Nat) : Coe SKI (SKI.Polynomial n) := ⟨SKI.Polynomial.term⟩
265
leanexplore_declaration
leanexplore:387726
leanexplore_sqlite
leanexplore_declarations
/-- Substitute terms for the free variables of a polynomial -/ def Polynomial.eval {n : Nat} (Γ : SKI.Polynomial n) (l : List SKI) (hl : List.length l = n) : SKI := match Γ with | .term x => x | .var i => l[i] | .app Γ Δ => (Γ.eval l hl) ⬝ (Δ.eval l hl)
135
leanexplore_declaration
leanexplore:387727
leanexplore_sqlite
leanexplore_declarations
/-- A polynomial with no free variables is a term -/ def Polynomial.varFreeToSKI (Γ : SKI.Polynomial 0) : SKI := Γ.eval [] (by trivial)
692
leanexplore_declaration
leanexplore:387728
leanexplore_sqlite
leanexplore_declarations
/-- Inductively define a polynomial `Γ'` so that (up to the fact that we haven't defined reduction on polynomials) `Γ' ⬝ t ↠ Γ[xₙ ← t]`. -/ def Polynomial.elimVar {n : Nat} : SKI.Polynomial (n+1) → SKI.Polynomial n /- The K-combinator leaves plain terms unchanged by substitution `K ⬝ x ⬝ t ⇒ x` -/ | .term x => K ⬝'...
1,541
leanexplore_declaration
leanexplore:387729
leanexplore_sqlite
leanexplore_declarations
/-- Correctness for the elimVar algorithm, which provides the inductive step of the bracket abstraction algorithm. We induct backwards on the list, corresponding to applying the transformation from the inside out. Since we haven't defined reduction for polynomials, we substitute arbitrary terms for the inner variables....
202
leanexplore_declaration
leanexplore:387730
leanexplore_sqlite
leanexplore_declarations
/-- Bracket abstraction, by induction using `SKI.Polynomial.elimVar` -/ def Polynomial.toSKI {n : Nat} (Γ : SKI.Polynomial n) : SKI := match n with | 0 => Γ.varFreeToSKI | _ + 1 => Γ.elimVar.toSKI
1,058
leanexplore_declaration
leanexplore:387731
leanexplore_sqlite
leanexplore_declarations
/-- Correctness for the toSKI (bracket abstraction) algorithm. -/ theorem Polynomial.toSKI_correct {n : Nat} (Γ : SKI.Polynomial n) (xs : List SKI) (hxs : xs.length = n) : Γ.toSKI.applyList xs ↠ Γ.eval xs hxs := by match n with | 0 => rw [List.length_eq_zero_iff] at hxs simp_rw [hxs, applyList, List.fol...
73
leanexplore_declaration
leanexplore:387732
leanexplore_sqlite
leanexplore_declarations
/-- Reversal: R := λ x y. y x -/ def RPoly : SKI.Polynomial 2 := &1 ⬝' &0
59
leanexplore_declaration
leanexplore:387733
leanexplore_sqlite
leanexplore_declarations
/-- A SKI term representing R -/ def R : SKI := RPoly.toSKI
89
leanexplore_declaration
leanexplore:387734
leanexplore_sqlite
leanexplore_declarations
theorem R_def (x y : SKI) : (R ⬝ x ⬝ y) ↠ y ⬝ x := RPoly.toSKI_correct [x, y] (by simp)
90
leanexplore_declaration
leanexplore:387735
leanexplore_sqlite
leanexplore_declarations
/-- Composition: B := λ f g x. f (g x) -/ def BPoly : SKI.Polynomial 3 := &0 ⬝' (&1 ⬝' &2)
59
leanexplore_declaration
leanexplore:387736
leanexplore_sqlite
leanexplore_declarations
/-- A SKI term representing B -/ def B : SKI := BPoly.toSKI
104
leanexplore_declaration
leanexplore:387737
leanexplore_sqlite
leanexplore_declarations
theorem B_def (f g x : SKI) : (B ⬝ f ⬝ g ⬝ x) ↠ f ⬝ (g ⬝ x) := BPoly.toSKI_correct [f, g, x] (by simp)
160
leanexplore_declaration
leanexplore:387738
leanexplore_sqlite
leanexplore_declarations
/-- B followed by tail reduction -/ lemma B_tail_mred (f g x y : SKI) (h : (g ⬝ x) ↠ y) : (B ⬝ f ⬝ g ⬝ x) ↠ f ⬝ y := Trans.trans (B_def f g x) (MRed.tail f h)
73
leanexplore_declaration
leanexplore:387739
leanexplore_sqlite
leanexplore_declarations
/-- C := λ f x y. f y x -/ def CPoly : SKI.Polynomial 3 := &0 ⬝' &2 ⬝' &1
59
leanexplore_declaration
leanexplore:387740
leanexplore_sqlite
leanexplore_declarations
/-- A SKI term representing C -/ def C : SKI := CPoly.toSKI
102
leanexplore_declaration
leanexplore:387741
leanexplore_sqlite
leanexplore_declarations
theorem C_def (f x y : SKI) : (C ⬝ f ⬝ x ⬝ y) ↠ f ⬝ y ⬝ x := CPoly.toSKI_correct [f, x, y] (by simp)
160
leanexplore_declaration
leanexplore:387742
leanexplore_sqlite
leanexplore_declarations
/-- C followed by head reduction -/ lemma C_head_mred (f x y z : SKI) (h : (f ⬝ y) ↠ z) : (C ⬝ f ⬝ x ⬝ y) ↠ z ⬝ x := Trans.trans (C_def f x y) (MRed.head x h)
93
leanexplore_declaration
leanexplore:387743
leanexplore_sqlite
leanexplore_declarations
/-- Rotate right: RotR := λ x y z. z x y -/ def RotRPoly : SKI.Polynomial 3 := &2 ⬝' &0 ⬝' &1
68
leanexplore_declaration
leanexplore:387744
leanexplore_sqlite
leanexplore_declarations
/-- A SKI term representing RotR -/ def RotR : SKI := RotRPoly.toSKI
111
leanexplore_declaration
leanexplore:387745
leanexplore_sqlite
leanexplore_declarations
theorem rotR_def (x y z : SKI) : (RotR ⬝ x ⬝ y ⬝ z) ↠ z ⬝ x ⬝ y := RotRPoly.toSKI_correct [x, y, z] (by simp)
92
leanexplore_declaration
leanexplore:387746
leanexplore_sqlite
leanexplore_declarations
/-- Rotate left: RotR := λ x y z. y z x -/ def RotLPoly : SKI.Polynomial 3 := &1 ⬝' &2 ⬝' &0
68
leanexplore_declaration
leanexplore:387747
leanexplore_sqlite
leanexplore_declarations
/-- A SKI term representing RotL -/ def RotL : SKI := RotLPoly.toSKI
111
leanexplore_declaration
leanexplore:387748
leanexplore_sqlite
leanexplore_declarations
theorem rotL_def (x y z : SKI) : (RotL ⬝ x ⬝ y ⬝ z) ↠ y ⬝ z ⬝ x := RotLPoly.toSKI_correct [x, y, z] (by simp)