11import RelationalAlgebra.Equivalence.RAtoFOL.ProjectionDef
22import RelationalAlgebra.FOL.RelabelProperties
33
4- open RM
4+ open RM FOL
55
66variable {ρ α : Type } [LinearOrder α]
77
88/-- Function to handle conversion of all Relational Algebra query cases. -/
99def toFOL (dbs : ρ → Finset α) : RA.Query ρ α → FOL.Query dbs
10- | .R rn => .R rn (FOL.outVar ∘ RelationSchema.fromIndex)
11- | .s a b sq => .and (toFOL dbs sq) (.tEq (FOL.outVar a) (FOL.outVar b))
10+ | .R rn => .R rn (freeVar ∘ RelationSchema.fromIndex)
11+ | .s a b sq => .and (toFOL dbs sq) (.tEq (freeVar a) (freeVar b))
1212 | .p rs sq => projectQuery (toFOL dbs sq) rs
1313 | .j sq₁ sq₂ => .and (toFOL dbs sq₁) (toFOL dbs sq₂)
1414 | .r f sq => (toFOL dbs sq).relabel (Sum.inl ∘ f)
@@ -21,8 +21,8 @@ theorem toFOL.schema_def {dbs : ρ → Finset α} {raQ : RA.Query ρ α} (h : ra
2121 induction raQ with
2222 | R rn =>
2323 ext a
24- simp_all only [RA.Query.isWellTyped, toFOL, FOL. BoundedQuery.schema.R_def,
25- Function.comp_apply, FOL.outVar .def, FirstOrder.Language.Term.varFinsetLeft.eq_1,
24+ simp_all only [RA.Query.isWellTyped, toFOL, BoundedQuery.schema.R_def,
25+ Function.comp_apply, freeVar .def, FirstOrder.Language.Term.varFinsetLeft.eq_1,
2626 Finset.mem_singleton, Set.mem_toFinset, Set.mem_setOf_eq, RA.Query.schema]
2727 apply Iff.intro
2828 · intro ⟨w, h⟩
@@ -39,14 +39,14 @@ theorem toFOL.schema_def {dbs : ρ → Finset α} {raQ : RA.Query ρ α} (h : ra
3939 simp_all only [forall_const]
4040
4141 | r f sq ih => simp_all only [RA.Query.isWellTyped, toFOL,
42- FOL. BoundedQuery.relabel_schema, Function.comp_apply, Sum.getLeft?_inl, Part.coe_some,
42+ BoundedQuery.relabel_schema, Function.comp_apply, Sum.getLeft?_inl, Part.coe_some,
4343 Finset.pimage_some, RA.Query.schema]
4444
45- | s => simp_all only [RA.Query.isWellTyped, toFOL, FOL.outVar .def,
46- FOL. BoundedQuery.schema.and_def, FOL. BoundedQuery.schema.tEq_def,
45+ | s => simp_all only [RA.Query.isWellTyped, toFOL, freeVar .def,
46+ BoundedQuery.schema.and_def, BoundedQuery.schema.tEq_def,
4747 FirstOrder.Language.Term.varFinsetLeft, Finset.union_singleton, Finset.union_insert,
4848 Finset.insert_eq_of_mem, RA.Query.schema]
4949
50- | _ => simp_all only [RA.Query.isWellTyped, toFOL, FOL. BoundedQuery.or,
51- FOL. BoundedQuery.schema.not_def, FOL. BoundedQuery.schema.and_def, Finset.union_idempotent,
50+ | _ => simp_all only [RA.Query.isWellTyped, toFOL, BoundedQuery.or,
51+ BoundedQuery.schema.not_def, BoundedQuery.schema.and_def, Finset.union_idempotent,
5252 RA.Query.schema]
0 commit comments