11import RelationalAlgebra.Equivalence.FOLtoRA.Adom
22import RelationalAlgebra.Equivalence.FOLtoRA.Disjoint
33import RelationalAlgebra.Equivalence.FOLtoRA.FRan
4- import RelationalAlgebra.Equivalence.FOLtoRA.NonemptyR
54import RelationalAlgebra.Equivalence.FOLtoRA.Conversion
65import RelationalAlgebra.FOL.Schema
76import RelationalAlgebra.FOL.Evaluate
@@ -117,15 +116,15 @@ theorem toRA.isWellTyped_def_IsPrenex [Nonempty ρ] {q : (fol dbs).BoundedFormul
117116
118117/- Proof that `toRA` evaluation is equivalent to the `Set` of tuples of `RealizeDomSet` for the distinct prenex form cases -/
119118theorem toRA.evalT_def_IsAtomic [Nonempty ρ] [Inhabited μ] [Nonempty ↑(adomRs dbi.schema)] [folStruc dbi] {q : (fol dbi.schema).BoundedFormula α n}
120- (hq : q.IsAtomic) [Fintype (adomRs dbi.schema)] (h : (q.freeVarFinset ∪ FRan (FreeMap n brs)) ⊆ rs) (hn : n + depth q < brs.card)
121- (hdisj : disjointSchema brs q) (hdef : default ∉ rs) (hne : NonemptyR q) :
119+ (hμ : ∀v, v ∈ dbi.domain) ( hq : q.IsAtomic) [Fintype (adomRs dbi.schema)] (h : (q.freeVarFinset ∪ FRan (FreeMap n brs)) ⊆ rs) (hn : n + depth q < brs.card)
120+ (hdisj : disjointSchema brs q) (hdef : default ∉ rs) :
122121 (toRA q rs brs).evaluateT dbi = RealizeDomSet q rs brs := by
123122 induction hq with
124123 | equal t₁ t₂ => exact equal_def h
125124 | rel R ts =>
126125 cases R with
127126 | R rn =>
128- apply relToRA.evalT_def h hdef ?_ hne
127+ apply relToRA.evalT_def h hdef ?_ hμ
129128
130129 simp [Relations.boundedFormula, disjointSchema, Finset.ext_iff] at hdisj
131130
@@ -150,21 +149,21 @@ theorem toRA.evalT_def_IsAtomic [Nonempty ρ] [Inhabited μ] [Nonempty ↑(adomR
150149
151150theorem toRA.evalT_def_IsQF [Nonempty ρ] [Inhabited μ] [folStruc dbi] {q : (fol dbi.schema).BoundedFormula α n}
152151 (hμ : ∀v, v ∈ dbi.domain) (hq : q.IsQF) [Fintype (adomRs dbi.schema)] [Nonempty ↑(adomRs dbi.schema)]
153- (h : (q.freeVarFinset ∪ FRan (FreeMap n brs)) ⊆ rs) (hn : n + depth q < brs.card) (hdisj : disjointSchema brs q) (hdef : default ∉ rs) (hne : NonemptyR q) :
152+ (h : (q.freeVarFinset ∪ FRan (FreeMap n brs)) ⊆ rs) (hn : n + depth q < brs.card) (hdisj : disjointSchema brs q) (hdef : default ∉ rs) :
154153 (toRA q rs brs).evaluateT dbi = RealizeDomSet q rs brs := by
155154 induction hq with
156155 | falsum => exact falsum_def
157- | of_isAtomic h_at => exact toRA.evalT_def_IsAtomic h_at h hn hdisj hdef hne
156+ | of_isAtomic h_at => exact toRA.evalT_def_IsAtomic hμ h_at h hn hdisj hdef
158157
159158 | imp h_qf₁ h_qf₂ ih₁ ih₂ =>
160159 rw [Finset.union_subset_iff, BoundedFormula.freeVarFinset, Finset.union_subset_iff] at h
161160
162161 exact toRA.imp_def hμ
163- (ih₁ (Finset.union_subset_iff.mpr ⟨h.1 .1 , h.2 ⟩) (by simp at hn; grind) (by simp at hdisj; exact ⟨hdisj.1 .1 , hdisj.2 ⟩) (hne. 1 ) )
164- (ih₂ (Finset.union_subset_iff.mpr ⟨h.1 .2 , h.2 ⟩) (by simp at hn; grind) (by simp at hdisj; exact ⟨hdisj.1 .2 , hdisj.2 ⟩) (hne. 2 ) )
162+ (ih₁ (Finset.union_subset_iff.mpr ⟨h.1 .1 , h.2 ⟩) (by simp at hn; grind) (by simp at hdisj; exact ⟨hdisj.1 .1 , hdisj.2 ⟩))
163+ (ih₂ (Finset.union_subset_iff.mpr ⟨h.1 .2 , h.2 ⟩) (by simp at hn; grind) (by simp at hdisj; exact ⟨hdisj.1 .2 , hdisj.2 ⟩))
165164
166165theorem toRA.evalT_def_IsPrenex [Nonempty ρ] [Inhabited μ] [folStruc dbi] {q : (fol dbi.schema).BoundedFormula α n} [Fintype (adomRs dbi.schema)] [Nonempty ↑(adomRs dbi.schema)]
167- (hμ : ∀v, v ∈ dbi.domain) (hq : q.IsPrenex) (h' : brs ∩ q.freeVarFinset = ∅) (hn : n + depth q < brs.card) (hdisj : disjointSchema brs q) (hdef : default ∉ q.freeVarFinset ∪ brs) (hne : NonemptyR q) :
166+ (hμ : ∀v, v ∈ dbi.domain) (hq : q.IsPrenex) (h' : brs ∩ q.freeVarFinset = ∅) (hn : n + depth q < brs.card) (hdisj : disjointSchema brs q) (hdef : default ∉ q.freeVarFinset ∪ brs) :
168167 (toRA q (q.freeVarFinset ∪ FRan (FreeMap n brs)) brs).evaluateT dbi = RealizeDomSet q (q.freeVarFinset ∪ FRan (FreeMap n brs)) brs := by
169168 induction hq with
170169 | of_isQF hqf =>
@@ -173,14 +172,14 @@ theorem toRA.evalT_def_IsPrenex [Nonempty ρ] [Inhabited μ] [folStruc dbi] {q :
173172 simp at ⊢ hdef;
174173 apply And.intro hdef.1 (FreeMap.notMem_notMem_FRan ?_ hdef.2 )
175174 grind
176- exact evalT_def_IsQF hμ hqf (fun ⦃a⦄ a ↦ a) hn hdisj hdef' hne
175+ exact evalT_def_IsQF hμ hqf (fun ⦃a⦄ a ↦ a) hn hdisj hdef'
177176
178177 | all hφ ih =>
179178 apply all_def hμ (by grind) ?_
180179
181180 . simp [← Nat.add_assoc] at hn
182181
183- exact ih h' hn hdisj hdef hne
182+ exact ih h' hn hdisj hdef
184183
185184 . simp [Finset.eq_empty_iff_forall_notMem] at h'
186185 apply h'
@@ -200,10 +199,10 @@ theorem toRA.evalT_def_IsPrenex [Nonempty ρ] [Inhabited μ] [folStruc dbi] {q :
200199
201200 . rw [helper φ]
202201 simp_rw [BoundedFormula.freeVarFinset, Finset.union_empty] at h' ⊢ hdef
203- simp at hdisj hne
202+ simp at hdisj
204203 simp [← Nat.add_assoc] at hn
205204
206- exact ih h' hn hdisj hdef hne
205+ exact ih h' hn hdisj hdef
207206
208207 . simp [Finset.eq_empty_iff_forall_notMem] at h'
209208 simp
@@ -235,7 +234,7 @@ theorem fol_to_ra_query.isWellTyped_def [Nonempty ρ] (q : FOL.Query dbs) [Finty
235234
236235/-- Conversion evaluation `Set` tuples equivalence proof (all tuples are restricted to `DatabaseInstance.domain`) -/
237236theorem fol_to_ra_query.evalT [folStruc dbi] [Fintype (adomRs dbi.schema)] [Nonempty ↑(adomRs dbi.schema)] [Inhabited μ] [Nonempty ρ]
238- (q : FOL.Query dbi.schema) (hμ : ∀v, v ∈ dbi.domain) (hdisj : disjointSchema brs q.toFormula) (hdef : default ∉ q.schema) (hne : NonemptyR q.toFormula)
237+ (q : FOL.Query dbi.schema) (hμ : ∀v, v ∈ dbi.domain) (hdisj : disjointSchema brs q.toFormula) (hdef : default ∉ q.schema)
239238 (hbrs : q.schema ∩ brs = ∅) (hdepth : 0 + depth (toPrenex q) < brs.card) (hdef' : default ∉ brs) :
240239 RA.Query.evaluateT dbi (fol_to_ra_query q brs) = FOL.Query.evaluateT dbi q ∩ {t | t.ran ⊆ dbi.domain} := by
241240 rw [FOL.Query.evaluateT, Set.ext_iff]
@@ -248,7 +247,7 @@ theorem fol_to_ra_query.evalT [folStruc dbi] [Fintype (adomRs dbi.schema)] [None
248247 have hq := BoundedFormula.toPrenex_isPrenex (BoundedQuery.toFormula q)
249248 have helper : (BoundedQuery.toFormula q).toPrenex.freeVarFinset ∪ FRan (FreeMap 0 brs)
250249 = (BoundedQuery.toFormula q).toPrenex.freeVarFinset := by simp [FRan]
251- rw [← freeVarFinset_toPrenex, ← helper, toRA.evalT_def_IsPrenex hμ hq ?_ ?_ ?_ ?_ ?_ ]
250+ rw [← freeVarFinset_toPrenex, ← helper, toRA.evalT_def_IsPrenex hμ hq ?_ ?_ ?_ ?_]
252251
253252 rw [Set.mem_setOf_eq]
254253 simp only [BoundedFormula.realize_toPrenex, RealizeDomSet]
@@ -263,4 +262,3 @@ theorem fol_to_ra_query.evalT [folStruc dbi] [Fintype (adomRs dbi.schema)] [None
263262 . exact ⟨(disjointSchemaL.toPrenex (BoundedQuery.toFormula q)).mpr hdisj.1 , hdisj.2 ⟩
264263 . simp only [freeVarFinset_toPrenex, Finset.mem_union, not_or]
265264 exact ⟨hdef, hdef'⟩
266- . exact (NonemptyR.toPrenex (BoundedQuery.toFormula q)).mpr hne
0 commit comments