Skip to content

Commit 4456808

Browse files
committed
Add proof of first-order factorization rule
1 parent c816481 commit 4456808

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

InferenceInLean/Resolution.lean

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ def GroundResolutionRule (A : Atom sig Empty) (C D : Clause sig Empty) : Inferen
2727
def GroundFactorizationRule (A : Atom sig Empty) (C : Clause sig Empty) : Inference sig Empty :=
2828
⟨{.pos A :: .pos A :: C}, .pos A :: C, True⟩
2929

30-
/--
31-
Both rules of the Resolution Calculus.
32-
Note that at the moment this is an inference system.
33-
Ideally we could somehow move the `A C D` inside the rules to use factorization without `D`.
34-
-/
30+
/-- Both rules of the Resolution Calculus. -/
3531
@[simp]
3632
def GroundResolution (sig : Signature) (A : Atom sig Empty) (C D : Clause sig Empty) :
3733
InferenceSystem sig Empty :=
@@ -185,15 +181,7 @@ theorem generalResolutionRuleSound [DecidableEq X] (A B : Atom sig X) (C D : Cla
185181
· exact hCσ
186182

187183
have hBσeqAσ: ∀ (β : Assignment X univ), Atom.eval I β (A.substitute σ)
188-
= Atom.eval I β (B.substitute σ) := by
189-
intro β
190-
have hunif : A.substitute σ = B.substitute σ := by
191-
obtain ⟨hσunif, _⟩ := hmgu
192-
simp only [Unifier, EqualityProblem.eq_1, List.mem_singleton, Atom.substitute,
193-
Atom.pred.injEq, forall_eq] at hσunif
194-
simp only [Atom.substitute, Atom.pred.injEq]
195-
exact hσunif
196-
rw [hunif]
184+
= Atom.eval I β (B.substitute σ) := by aesop
197185

198186
have hCDσ : ∀ β' : Assignment X univ, EntailsInterpret I β' (Clause.substitute σ (D ++ C)) := by
199187
intro β'
@@ -215,5 +203,35 @@ theorem generalResolutionRuleSound [DecidableEq X] (A B : Atom sig X) (C D : Cla
215203
generalize List.map (Literal.substitute σ) C = C'
216204
apply (@eval_append_iff_eval_or sig X univ _ I β' D' C').mpr
217205
aesop
218-
219206
exact validclosed_of_valid hCDσ β
207+
208+
theorem generalFactorizationRuleSound [DecidableEq X] (A B : Atom sig X) (C : Clause sig X)
209+
(σ : Substitution sig X) (hmgu : MostGeneralUnifier [(A, B)] σ) :
210+
@Entails _ _ univ _
211+
(Clause.toClosedFormula sig X (.pos B :: .pos A :: C))
212+
((Clause.substitute σ (.pos A :: C)).toClosedFormula) := by
213+
intro I β hentails
214+
let pre_inner : Clause sig X := (.pos B :: .pos A :: C)
215+
let pre : Formula sig X := pre_inner.toClosedFormula
216+
have hpreclosed : pre.closed := by exact Clause.closedClause_closed sig X pre_inner
217+
have hprevalid : ValidIn pre I := validIn_of_entails_closed I _ hpreclosed (by use β)
218+
219+
-- use 3.3.8
220+
let prexs : List X := pre_inner.freeVarsList
221+
let pren : ℕ := prexs.length
222+
have hprexsnodup : prexs.Nodup := by exact nodup_clauseFreeVarsList sig X pre_inner
223+
let preys : List X := (pre_inner.substitute σ).freeVarsList
224+
let prem : ℕ := preys.length
225+
have hpreysnodup : preys.Nodup := by
226+
exact nodup_clauseFreeVarsList sig X (Clause.substitute σ pre_inner)
227+
have h338 := three_three_eight _ _ σ _ _ _ _ hprexsnodup rfl hpreysnodup rfl hprevalid
228+
229+
-- use 3.3.7
230+
have hpreinnersub : @ValidIn _ X _ _ (pre_inner.substitute σ) I := by
231+
exact (three_three_seven preys.length
232+
(Clause.toFormula sig X (Clause.substitute σ pre_inner)) I preys hpreysnodup rfl).mp
233+
h338
234+
235+
have hACσ : ∀ β' : Assignment X _, EntailsInterpret I β' (Clause.substitute σ (.pos A :: C)) := by
236+
aesop
237+
exact validclosed_of_valid hACσ β

0 commit comments

Comments
 (0)