Skip to content

Commit ad8e9e7

Browse files
committed
Removed BoundedQuery.or Constructor
1 parent f4cb19e commit ad8e9e7

6 files changed

Lines changed: 12 additions & 38 deletions

File tree

RelationalAlgebra/Equivalence/RAtoFOL/Conversion.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ theorem ra_to_fol_query_schema {dbs : ρ → Finset α} {raQ : RA.Query ρ α} (
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, ra_to_fol_query, FOL.BoundedQuery.schema.and_def,
51-
FOL.BoundedQuery.schema.or_def, FOL.BoundedQuery.schema.not_def, Finset.union_idempotent, RA.Query.schema]
50+
| _ => simp_all only [RA.Query.isWellTyped, ra_to_fol_query, FOL.BoundedQuery.or,
51+
FOL.BoundedQuery.schema.not_def, FOL.BoundedQuery.schema.and_def, Finset.union_idempotent,
52+
RA.Query.schema]

RelationalAlgebra/Equivalence/RAtoFOL/Union.lean

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,4 @@ theorem ra_to_fol_evalT.u_def_eq (h : RA.Query.isWellTyped dbi.schema (.u q₁ q
1515
simp_all only [Set.mem_setOf_eq, Set.mem_union]
1616
obtain ⟨left, right⟩ := h
1717
obtain ⟨left_1, right⟩ := right
18-
apply Iff.intro
19-
· intro a
20-
simp_all only [forall_true_left, true_and]
21-
obtain ⟨left_2, right_1⟩ := a
22-
convert right_1 left_2
23-
· intro a
24-
cases a with
25-
| inl h =>
26-
simp_all only [forall_true_left, true_and]
27-
obtain ⟨left_2, right_1⟩ := h
28-
apply Or.inl
29-
convert right_1 left_2
30-
| inr h_1 =>
31-
simp_all only [forall_true_left, true_and]
32-
obtain ⟨left_2, right_1⟩ := h_1
33-
apply Or.inr
34-
convert right_1 left_2
18+
grind only [cases Or]

RelationalAlgebra/FOL/Query.lean

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@ inductive BoundedQuery (dbs : ρ → Finset α) : ℕ → Type
1818
| and {n} (q1 q2 : BoundedQuery dbs n): BoundedQuery dbs n
1919
| tEq {n} : (t₁ t₂ : (fol dbs).Term (α ⊕ Fin n)) → BoundedQuery dbs n
2020
| ex {n} (q : BoundedQuery dbs (n + 1)) : BoundedQuery dbs n
21-
| or {n} (q₁ q₂ : BoundedQuery dbs n) : BoundedQuery dbs n
2221
| not {n} (q : BoundedQuery dbs n) : BoundedQuery dbs n
2322

23+
@[simp]
24+
def BoundedQuery.or (q₁ q₂ : BoundedQuery dbs n) : BoundedQuery dbs n :=
25+
(q₁.not.and (q₂.not)).not
26+
27+
@[simp]
28+
def BoundedQuery.all (q : BoundedQuery dbs (n + 1)) : BoundedQuery dbs n :=
29+
q.not.ex.not
30+
2431
/-- Syntax for a `Query` given a database schema `dbs` with bound `0`. Similar to `ModelTheory.Formula`. -/
2532
abbrev Query (dbs : ρ → Finset α) := BoundedQuery dbs 0
2633

@@ -38,7 +45,6 @@ def BoundedQuery.toFormula : (q : BoundedQuery dbs n) → (fol dbs).BoundedFormu
3845
| .tEq t₁ t₂ => .equal t₁ t₂
3946
| .and q1 q2 => q1.toFormula ⊓ q2.toFormula
4047
| .ex q => .ex q.toFormula
41-
| .or q1 q2 => q1.toFormula ⊔ q2.toFormula
4248
| .not q => .not q.toFormula
4349

4450
@[simp]

RelationalAlgebra/FOL/RealizeProperties.lean

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,4 @@ theorem BoundedQuery.Realize.restrict [folStruc dbi] {rs : Finset α} {q : Bound
294294
have : f₁.toFormula.freeVarFinset ⊆ rs := Finset.union_subset_left h_min
295295
have : f₂.toFormula.freeVarFinset ⊆ rs := Finset.union_subset_right h_min
296296
simp_all
297-
| or f₁ f₂ ih₁ ih₂ =>
298-
simp_all [BoundedQuery.toFormula]
299-
have : f₁.toFormula.freeVarFinset ⊆ rs := Finset.union_subset_left h_min
300-
have : f₂.toFormula.freeVarFinset ⊆ rs := Finset.union_subset_right h_min
301-
simp_all
302297
| _ => simp_all

RelationalAlgebra/FOL/Relabel.lean

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def BoundedQuery.mapTermRel {g : ℕ → ℕ} (ft : ∀ n, (fol dbs).Term (α
1616
| _n, .tEq a b => .tEq (ft _ a) (ft _ b)
1717
| _n, .and q1 q2 => .and (q1.mapTermRel ft h) (q2.mapTermRel ft h)
1818
| n, .ex q => (h n (q.mapTermRel ft h)).ex
19-
| _n, .or q1 q2 => .or (q1.mapTermRel ft h) (q2.mapTermRel ft h)
2019
| _n, .not q => (q.mapTermRel ft h).not
2120

2221
/-- Casts `BoundedQuery dbs m` as `BoundedQuery dbs n`, where `m ≤ n`. -/
@@ -26,7 +25,6 @@ def BoundedQuery.castLE : ∀ {m n : ℕ} (_h : m ≤ n), BoundedQuery dbs m →
2625
| _m, _n, h, .tEq a b => .tEq (a.relabel (Sum.map id (Fin.castLE h))) (b.relabel (Sum.map id (Fin.castLE h)))
2726
| _m, _n, h, .and q₁ q₂ => (q₁.castLE h).and (q₂.castLE h)
2827
| _m, _n, h, .ex q => (q.castLE (add_le_add_right h 1)).ex
29-
| _m, _n, h, .or q₁ q₂ => (q₁.castLE h).or (q₂.castLE h)
3028
| _m, _n, h, .not q => (q.castLE h).not
3129

3230
/- Helper theorems for `castLE` and `mapTermRel` -/
@@ -44,7 +42,6 @@ theorem castLE_rfl {n} (h : n ≤ n) (φ : BoundedQuery dbs n) : φ.castLE h =
4442
| tEq _ _ => simp
4543
| and _ _ ih₁ ih₂ => simp [ih₁, ih₂]
4644
| ex _ ih => simp [ih]
47-
| or _ _ ih₁ ih₂ => simp [ ih₁, ih₂]
4845
| not _ ih => simp [ih]
4946

5047
@[simp]
@@ -102,11 +99,6 @@ theorem BoundedQuery.relabel.ex_def (g : α → α ⊕ (Fin n)) {k} (φ : Bounde
10299
rw [relabel, mapTermRel, relabel]
103100
simp
104101

105-
@[simp]
106-
theorem BoundedQuery.relabel.or_def (g : α → α ⊕ (Fin n)) {k} (φ ψ : BoundedQuery dbs k) :
107-
(or φ ψ).relabel g = or (φ.relabel g) (ψ.relabel g) := by
108-
rfl
109-
110102
@[simp]
111103
theorem BoundedQuery.relabel.not_def (g : α → α ⊕ (Fin n)) {k} (φ : BoundedQuery dbs k) :
112104
(not φ).relabel g = not (φ.relabel g) := by

RelationalAlgebra/FOL/Schema.lean

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ theorem BoundedQuery.schema.and_def {n : ℕ} (q₁ q₂ : BoundedQuery dbs n) :
4848
theorem BoundedQuery.schema.ex_def {n : ℕ} (q : BoundedQuery dbs (n + 1)) :
4949
(ex q).schema = q.schema := by simp_all [schema]
5050

51-
@[simp]
52-
theorem BoundedQuery.schema.or_def {n : ℕ} (q₁ q₂ : BoundedQuery dbs n) :
53-
(or q₁ q₂).schema = q₁.schema ∪ q₂.schema := by simp_all [schema]
54-
5551
@[simp]
5652
theorem BoundedQuery.schema.not_def {n : ℕ} (q : BoundedQuery dbs n) :
5753
(not q).schema = q.schema := by simp_all [schema]

0 commit comments

Comments
 (0)