Skip to content

Commit f7f20f8

Browse files
committed
delete deprecated EqnLemma and related defs/theorems
1 parent d034a3b commit f7f20f8

1 file changed

Lines changed: 0 additions & 226 deletions

File tree

EffectSSA/ProofSketch/ProofSketch.lean

Lines changed: 0 additions & 226 deletions
Original file line numberDiff line numberDiff line change
@@ -25,191 +25,6 @@ namespace EffectSSA.ProofSketch
2525

2626
variable [SSA ι σ ν]
2727

28-
/-!
29-
## Equation Lemma
30-
-/
31-
section EqnLemma
32-
33-
def Inst.EqnLemma (i : Inst ι) (x : VarId) (ρ : SEnv ι) : Prop :=
34-
x ∈ i.results → (⟦i⟧ ρ).locals x = ρ.locals x
35-
36-
@[grind] def InstSeq.EqnLemma (is : InstSeq ι) (x : VarId) (ρ : SEnv ι) : Prop :=
37-
∀ i ∈ is, Inst.EqnLemma i x ρ
38-
39-
@[grind] def Pattern.EqnLemma (I : Pattern ι n) (x : VarId) (ρ : SEnv ι) : Prop :=
40-
∀ i ∈ I, InstSeq.EqnLemma i x ρ
41-
42-
-- TODO: HasEqn should probably be called WellBehaved or some such
43-
44-
/--
45-
We say that an instruction `i` has a well-behaved equation lemma when:
46-
47-
* validity of the equation lemma is stable under the execution of more instructions, and
48-
* executing `i` is guaranteed to yield an environment that satisfies its
49-
own equation lemma
50-
-/
51-
structure Inst.HasEqn (i : Inst ι) : Prop where
52-
stable : ∀ x ρ, Inst.EqnLemma i x ρ → ∀ j : Inst ι, x ∉ j.results → Inst.EqnLemma i x (⟦j⟧ ρ)
53-
idempotent : ∀ x ρ, Inst.EqnLemma i x (⟦i⟧ ρ)
54-
55-
@[grind] def InstSeq.HasEqn (is : InstSeq ι) : Prop :=
56-
∀ i ∈ is, Inst.HasEqn i
57-
58-
@[grind] def Pattern.HasEqn (I : Pattern ι n) : Prop :=
59-
∀ i ∈ I, InstSeq.HasEqn i
60-
61-
section Lemmas
62-
variable {i : Inst ι} {is : InstSeq ι} {I : Pattern ι n}
63-
64-
/-! vacuous -/
65-
66-
@[grind =>] theorem Inst.eqnLemma_of_not_mem_results {ρ : SEnv ι} (hx : x ∉ i.results) :
67-
EqnLemma i x ρ := by
68-
grind [EqnLemma]
69-
70-
@[grind =>] theorem InstSeq.eqnLemma_of_not_mem_results {ρ : SEnv ι} (hx : x ∉ is.results) :
71-
EqnLemma is x ρ := by
72-
intro i hi
73-
grind
74-
75-
@[grind =>] theorem Pattern.eqnLemma_of_not_mem_results {ρ : SEnv ι} (hx : x ∉ I.results) :
76-
EqnLemma I x ρ := by
77-
intro is his
78-
grind
79-
80-
/-! structural lemmas -/
81-
variable (I : Pattern ι n) (is : InstSeq ι)
82-
83-
@[simp, grind .] theorem InstSeq.EqnLemma_nil {ρ : SEnv ι} :
84-
InstSeq.EqnLemma ([] : InstSeq ι) x ρ := by
85-
grind [InstSeq.EqnLemma]
86-
87-
@[simp, grind =] theorem InstSeq.EqnLemma_cons {i : Inst ι} {is : InstSeq ι} {ρ : SEnv ι} :
88-
InstSeq.EqnLemma (i ;> is) x ρ ↔ Inst.EqnLemma i x ρ ∧ InstSeq.EqnLemma is x ρ := by
89-
grind [InstSeq.EqnLemma]
90-
91-
variable {I} in
92-
@[grind .]
93-
theorem Pattern.eqnLemma_of_mem_results_get {k : Nat} {hk} {ρ : SEnv ι}
94-
(hx : x ∈ I[k].results) (wf : I.NoShadowing):
95-
Pattern.EqnLemma I x ρ ↔ InstSeq.EqnLemma I[k] x ρ := by
96-
generalize hi : I[k] = is
97-
constructor
98-
· grind
99-
· intro h js hj
100-
by_cases is = js; grind
101-
by_cases x ∈ is.results
102-
· have : x ∉ js.results := by
103-
have := results_disjoint_of_mem_of_noShadowing (by grind : is ∈ I) hj
104-
grind
105-
grind
106-
· grind
107-
108-
/-! stability -/
109-
110-
attribute [grind =>] Inst.HasEqn.stable
111-
112-
/--
113-
If `is.HasEqn`, then validity of the equation lemma is stable under the execution
114-
another instruction `j`.
115-
-/
116-
@[grind =>]
117-
theorem InstSeq.eqnLemma_of_eqnLemma_inst {ρ : SEnv ι} (hEqn : HasEqn is) :
118-
EqnLemma is x ρ → ∀ j : Inst ι, x ∉ j.results → EqnLemma is x (⟦j⟧ ρ) := by
119-
grind
120-
121-
/--
122-
If `I.HasEqn`, then validity of the equation lemma is stable under the execution
123-
another instruction `j`.
124-
-/
125-
@[grind =>]
126-
theorem Pattern.eqnLemma_of_eqnLemma_inst {ρ : SEnv ι} (hEqn : HasEqn I) :
127-
EqnLemma I x ρ → ∀ j : Inst ι, x ∉ j.results → EqnLemma I x (⟦j⟧ ρ) := by
128-
grind
129-
130-
/--
131-
If `I.HasEqn`, then validity of the equation lemma is stable under the execution
132-
another sequence of instructions `js`.
133-
-/
134-
@[grind .]
135-
theorem Pattern.eqnLemma_of_eqnLemma_instSeq {ρ : SEnv ι} (hI : HasEqn I) :
136-
EqnLemma I x ρ → ∀ js : InstSeq ι, x ∉ js.results → EqnLemma I x (⟦js⟧ ρ) := by
137-
intro heqn js hjs
138-
induction js generalizing ρ
139-
· exact heqn
140-
· grind
141-
142-
/--
143-
If `i.HasEqn`, then validity of the equation lemma is stable under the execution
144-
another sequence of instructions `js`.
145-
-/
146-
@[grind .]
147-
theorem Inst.eqnLemma_of_eqnLemma_instSeq {i : Inst ι} {ρ : SEnv ι} (hi : HasEqn i) :
148-
EqnLemma i x ρ → ∀ js : InstSeq ι, x ∉ js.results → EqnLemma i x (⟦js⟧ ρ) := by
149-
intro heqn js hjs
150-
induction js generalizing ρ
151-
· exact heqn
152-
· grind
153-
154-
/-! denote lemmas -/
155-
156-
@[grind =] theorem Inst.locals_denote_of_eqnLemma {i : Inst ι} {ρ : SEnv ι}
157-
(h : EqnLemma i x ρ) : (⟦i⟧ ρ).locals x = ρ.locals x := by
158-
grind [EqnLemma]
159-
160-
@[grind .] theorem InstSeq.locals_denote_of_eqnLemma {is : InstSeq ι} {ρ : SEnv ι}
161-
(hEqn : HasEqn is)
162-
(hwf : is.NoShadowing) (h : EqnLemma is x ρ) :
163-
(⟦is⟧ ρ).locals x = ρ.locals x := by
164-
induction is generalizing ρ
165-
· rfl
166-
· grind
167-
168-
/-! idempotence -/
169-
170-
attribute [grind .] Inst.HasEqn.idempotent
171-
172-
/--
173-
If `is.HasEqn`, then evaluating `is` is guaranteed to yield an environment which
174-
satisfies its own equation lemma at any variable.
175-
-/
176-
@[grind =>]
177-
theorem InstSeq.eqnLemma_denote_self {is : InstSeq ι} (hEqn : HasEqn is)
178-
(hwf : is.NoShadowing) (ρ) :
179-
EqnLemma is x (⟦is⟧ ρ) := by
180-
induction is generalizing ρ
181-
· simp
182-
· simp; grind
183-
184-
end Lemmas
185-
186-
section EqnLemmaUpTo
187-
188-
/--
189-
`I.usesAt v` is an alias of `I.collapse.usesAt v`.
190-
191-
See `InstSeq.usesAt` for details.
192-
-/
193-
abbrev Pattern.usesAt (v : VarId) (I : Pattern ι n) := I.collapse.usesAt v
194-
195-
/--
196-
`I.getDef? v` is an alias of `I.collapse.getDef? v`.
197-
198-
See `InstSeq.getDef?` for details.
199-
-/
200-
abbrev Pattern.getDef? (v : VarId) (I : Pattern ι n) :=
201-
I.collapse.getDef? v
202-
203-
/--
204-
`I.EqnLemmaUpTo h ρ` holds when `ρ` satisfies the equation lemma for all
205-
(transitive) dependencies of the `h`-th pattern of `I`.
206-
-/
207-
def Pattern.EqnLemmaUpTo (I : Pattern ι n) (h : Hole n) (ρ : SEnv ι) : Prop :=
208-
∀ x ∈ I[h].args,
209-
∀ y, y = x ∨ y ∈ (I.usesAt x) → Pattern.EqnLemma I y ρ
210-
211-
end EqnLemmaUpTo
212-
end EqnLemma
21328

21429
/-!
21530
## Denotational Refinement & Equivalence
@@ -256,47 +71,6 @@ def Pattern.CtxRefine (I J : Pattern ι n) : Prop :=
25671
CI.WellFormed ∅ → CJ.WellFormed ∅ →
25772
⟦CI⟧ {} ⊒ ⟦CJ⟧ {}
25873

259-
/-!
260-
## Residual
261-
-/
262-
section Residual
263-
264-
/--
265-
We say that `Γ` is a residual of context `C` under pattern `I` when
266-
267-
TODO: dedup with Invariant
268-
-/
269-
@[grind, grind cases]
270-
private structure Residual (Γ : VarSet) (C : MultiContext ι n) (P : Pattern ι n) : Prop where
271-
/-- `H` is the list of previously seen holes -/
272-
residual : ∃ H : List (Hole n), C.CompleteMod H ∧ ∀ h ∈ H, P[h].results ⊆ Γ
273-
/-- `C.plug I` is well-formed with free variables `Γ`. -/
274-
wf : (C.plug P).WellFormed Γ
275-
276-
namespace Residual
277-
variable {Γ : VarSet} {C : MultiContext ι n} {P : Pattern ι n} {i : Inst ι} {h : Hole n}
278-
279-
/-! invariants -/
280-
281-
private theorem initial (wf : (C.plug P).WellFormed ∅) (hC : C.Complete) : Residual ∅ C P := by
282-
grind [Pattern.mem_iff_getElem_hole, MultiContext.CompleteMod]
283-
284-
@[grind →] private theorem of_cons_inst :
285-
Residual Γ (.inl i :: C) P → Residual (i.resultsSet ∪ Γ) C P := by
286-
rintro ⟨wf, residual⟩;
287-
constructor
288-
· simp_all; grind
289-
· simp_all
290-
291-
@[grind →] private theorem of_cons_hole :
292-
Residual Γ (.inr h :: C) P → Residual (P[h].results ∪ Γ) C P := by
293-
rintro ⟨wf, residual⟩; constructor
294-
· simp_all; grind
295-
· simp_all
296-
297-
end Residual
298-
end Residual
299-
30074
/-!
30175
## Main Result for straight-line programs
30276
-/

0 commit comments

Comments
 (0)