Skip to content

Commit b38a74b

Browse files
committed
Add some more documentation
1 parent 46e53ff commit b38a74b

4 files changed

Lines changed: 40 additions & 23 deletions

File tree

InferenceInLean/Inference.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ open Semantics
1111
open Models
1212
open Unification
1313

14-
/- ### 3.7 Inference Systems and Proofs -/
14+
/-! ### 3.7 Inference Systems and Proofs
15+
In this section we define inferences and proofs, allowing us to define syntactic entailment and
16+
soundness. -/
1517

1618
namespace Inferences
1719

InferenceInLean/Models.lean

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ set_option autoImplicit false
77
open Syntax
88
open Semantics
99

10-
/-! ## 3.3 Models, Validity, and Satisfiability -/
10+
/-! ## 3.3 Models, Validity, and Satisfiability
11+
In this section we establish various notions of semantic entailment and prove several lemmas that
12+
show how assignments and substitutions interact. -/
1113

1214
namespace Models
1315

@@ -50,6 +52,22 @@ theorem entails_iff_imp_valid [inst : DecidableEq X]
5052
(F G : Formula sig X) : @Entails _ _ univ _ F G ↔ @Valid _ _ univ _ (Formula.imp F G) :=
5153
Eq.to_iff rfl
5254

55+
/- N ⊨ F -/
56+
@[simp]
57+
def SetEntails [DecidableEq X]
58+
(N : Set (Formula sig X)) (F : Formula sig X) : Prop :=
59+
∀ (I : Interpretation sig univ) (β : Assignment X univ),
60+
(∀ G ∈ N, EntailsInterpret I β G) → EntailsInterpret I β F
61+
62+
@[simp]
63+
def ClauseSetEntails [DecidableEq X]
64+
(N : Set <| Clause sig X) (C : Clause sig X) : Prop :=
65+
∀ (I : Interpretation sig univ),
66+
(∀ D ∈ N, @ValidIn _ X _ _ D I) → @ValidIn _ X _ _ C I
67+
68+
lemma entails_setEntails [inst : DecidableEq X]
69+
(F G : Formula sig X) : @Entails _ _ univ _ F G ↔ @SetEntails _ X univ _ {F} G := by simp
70+
5371
/- ### Satsfiability -/
5472

5573
@[simp]
@@ -73,21 +91,6 @@ def Literal.satisfied_by [DecidableEq X]
7391
| Literal.pos a => Formula.atom a
7492
| Literal.neg a => Formula.neg (Formula.atom a)
7593

76-
@[simp]
77-
def SetEntails [DecidableEq X]
78-
(N : Set (Formula sig X)) (F : Formula sig X) : Prop :=
79-
∀ (I : Interpretation sig univ) (β : Assignment X univ),
80-
(∀ G ∈ N, EntailsInterpret I β G) → EntailsInterpret I β F
81-
82-
@[simp]
83-
def ClauseSetEntails [DecidableEq X]
84-
(N : Set <| Clause sig X) (C : Clause sig X) : Prop :=
85-
∀ (I : Interpretation sig univ),
86-
(∀ D ∈ N, @ValidIn _ X _ _ D I) → @ValidIn _ X _ _ C I
87-
88-
lemma entails_setEntails [inst : DecidableEq X]
89-
(F G : Formula sig X) : @Entails _ _ univ _ F G ↔ @SetEntails _ X univ _ {F} G := by simp
90-
9194
@[simp]
9295
def ClauseSatisfiable [DecidableEq X] (C : Clause sig X) : Prop :=
9396
∃ (I : Interpretation sig univ) (β : Assignment X univ),
@@ -168,8 +171,10 @@ lemma validIn_of_entails_closed {sig : Signature} {X : Variables} [inst : Decida
168171
exact hγ
169172

170173
/- ### Lemmas Related to Entailment
171-
In the following section, we prove several lemmas that will be vital in our soundness proof. -/
174+
In the following section, we prove several lemmas from the lecture notes that will be vital for our
175+
soundness proof. -/
172176

177+
/- Composition β ∘ σ of an assignment β with a substitution σ -/
173178
@[simp]
174179
def Assignment.compose [DecidableEq X] (I : Interpretation sig univ) (β : Assignment X univ)
175180
(σ : Substitution sig X) : Assignment X univ :=
@@ -191,6 +196,7 @@ lemma Assignment.compose_term_eq_eval_compose [DecidableEq X] (I : Interpretatio
191196
· simp_all only [compose_term, Term.eval.eq_1, compose]
192197
· simp_all only [compose_term, List.map_subtype, List.unattach_attach, Term.eval.eq_2]
193198

199+
/- I(β)(tσ) = I(β ∘ σ)(t) -/
194200
theorem substitution_lemma [DecidableEq X]
195201
(I : Interpretation sig univ) (β : Assignment X univ) (σ : Substitution _ _) (t : Term _ _) :
196202
Term.eval I β (t.substitute σ) = Term.eval I (Assignment.compose I β σ) t := by
@@ -207,6 +213,7 @@ theorem substitution_lemma [DecidableEq X]
207213
simp_all only [List.map_inj_left, Function.comp_apply, implies_true]
208214
rw [hargsarequal]
209215

216+
/- I(β)(Fσ) = A(β ∘ σ)(F) -/
210217
theorem three_three_five [DecidableEq X]
211218
(I : Interpretation sig univ) (β : Assignment X univ) (σ : Substitution _ _) (C : Clause _ _) :
212219
Formula.eval I β (C.substitute σ) = Formula.eval I (Assignment.compose I β σ) C := by
@@ -242,7 +249,9 @@ theorem three_three_six [DecidableEq X]
242249
rw [EntailsInterpret, EntailsInterpret, ← eq_iff_iff]
243250
exact three_three_five I β σ C
244251

245-
/- ### Lemma 3.3.7 -/
252+
/- A ⊨ ∀ x1, ..., xn F ↔ A ⊨ F
253+
Since we do not demand that F is a closed formula, this statement is slightly stronger than the
254+
one in the lecture notes. Regardless, this proof has the same structure as the one in the notes. -/
246255
lemma three_three_seven [DecidableEq X] (n : ℕ) (F : Formula sig X) (I : Interpretation sig univ)
247256
(xs : List X) (huniq : xs.Nodup) (hn : xs.length = n) :
248257
ValidIn (F.bigForall _ _ xs) I ↔ ValidIn F I := by
@@ -281,6 +290,7 @@ lemma three_three_seven [DecidableEq X] (n : ℕ) (F : Formula sig X) (I : Inter
281290
intro a
282291
exact ih (n - 1) (List.Nodup.of_cons huniq) (Nat.eq_sub_of_add_eq hn) (β.modify x a)
283292

293+
/- Used in the following proof. -/
284294
lemma valid_sub_of_valid {I : Interpretation sig univ} [DecidableEq X] (C : Clause sig X)
285295
(σ : Substitution sig X) :
286296
ValidIn (Clause.toFormula sig X C) I →
@@ -291,6 +301,7 @@ lemma valid_sub_of_valid {I : Interpretation sig univ} [DecidableEq X] (C : Clau
291301
rw [three_three_five]
292302
exact hvalid
293303

304+
/- A ⊨ ∀ x1, ..., xn F → A ⊨ ∀ y1, ..., yn F -/
294305
lemma three_three_eight {sig : Signature} {X : Variables} [DecidableEq X] (C : Clause sig X)
295306
(I : Interpretation sig univ) (σ : Substitution sig X) (n m : ℕ)
296307
(xs ys : List X) (hxuniq : xs.Nodup) (hn : xs.length = n)

InferenceInLean/Semantics.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ set_option autoImplicit false
55

66
open Syntax
77

8-
/- ## 3.2 Semantics
9-
Here, the syntatic definitions are expanded upon with semantic interpretations. -/
8+
/-! ## 3.2 Semantics
9+
In this section we expand our syntactic definitions with semantic interpretations, defining how
10+
to evaluate them under an assignment β. In addition, we define modifications of assignments and show
11+
that the evaluation of closed formulas does not depend on assignments. -/
1012

1113
namespace Semantics
1214

InferenceInLean/Syntax.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import Mathlib.Data.Finset.Range
33

44
set_option autoImplicit false
55

6-
/- ## 3.1 Syntax
7-
In the following only syntactical notions are defined. -/
6+
/-! ## 3.1 Syntax
7+
In this section, we define the basic syntactic notions for first-order logic. This includes terms,
8+
atoms, formulas, Literals, and clauses. For each of these constructs, we also define its set of
9+
free variables, and how substitutions act on them. -/
810

911
namespace Syntax
1012

0 commit comments

Comments
 (0)