Skip to content

Commit 70cf5b5

Browse files
committed
Restructure sections and add some documentation
1 parent 0094810 commit 70cf5b5

File tree

5 files changed

+221
-162
lines changed

5 files changed

+221
-162
lines changed

InferenceInLean/Examples.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import InferenceInLean.Basic
1+
import InferenceInLean.Resolution
22
import Mathlib.Data.Finset.Defs
33

44
set_option autoImplicit false

InferenceInLean/Inference.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ instance : Membership (Inference sig X) (InferenceSystem sig X) :=
3030

3131
variable {sig : Signature} {X : Variables} {univ : Universes}
3232

33+
/-- This formalization of proofs is one of several possible translations for the definition in the
34+
lecture notes, and is the one that ended up being the most ergonomic one to use for us. -/
3335
structure Proof (Γ : InferenceSystem sig X) where
3436
assumptions : Set (Clause sig X)
3537
conclusion : Clause sig X
@@ -43,19 +45,26 @@ structure Proof (Γ : InferenceSystem sig X) where
4345
∃ inference ∈ Γ, clauses[i] = inference.conclusion ∧ inference.condition ∧
4446
∀ Clause ∈ inference.premises, ∃ (j : ℕ) (hjindex : j < i), Clause = clauses[j]
4547

48+
/-- Syntactic entailment N ⊢ F in Γ. -/
4649
@[simp]
4750
def Provability (Γ : InferenceSystem sig X) (N : Set (Clause sig X)) (F : Clause sig X) : Prop :=
4851
∃ proof : Proof Γ, proof.assumptions = N ∧ proof.conclusion = F
4952

53+
/-- This is the soundness definition from the lecture notes, which is based on inferences. -/
5054
@[simp]
5155
def Soundness [inst : DecidableEq X] (Γ : InferenceSystem sig X) : Prop :=
5256
∀ inference ∈ Γ, inference.condition →
5357
@ClauseSetEntails _ _ univ _ inference.premises inference.conclusion
5458

59+
/-- This is the more general definition for soundness: An inference system Γ is sound if
60+
N ⊢ F → N ⊨ F. -/
5561
@[simp]
5662
def GeneralSoundness [inst : DecidableEq X] (Γ : InferenceSystem sig X) : Prop :=
5763
∀ (N : Set (Clause _ _)) (F : Clause _ _), Provability Γ N F → @ClauseSetEntails _ _ univ _ N F
5864

65+
/-- Proof that the more general definition of soundness follows from the inference-based one in
66+
the lecture notes. This means that we can show the soundness of an inference system Γ just by
67+
showing that all of its inferences are sound. -/
5968
theorem generalSoundness_of_soundness [inst : DecidableEq X]
6069
(Γ : InferenceSystem sig X) : @Soundness _ _ univ _ Γ → @GeneralSoundness _ _ univ _ Γ := by
6170
intro hsound N F hproof A β hgstrue

InferenceInLean/Models.lean

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ 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 -/
1111

1212
namespace Models
1313

1414
variable {sig : Signature} {X : Variables} {univ : Universes}
1515

16-
/- ### Σ-Algebra A with assignment β
17-
> I, β ⊨ F :⇔ I(β)(F) = True
18-
-/
16+
/- ### Truth and Validity -/
1917

18+
/-- I,β ⊨ F -/
2019
@[simp]
2120
def EntailsInterpret [DecidableEq X]
2221
(I : Interpretation sig univ) (β : Assignment X univ) (F : Formula sig X) : Prop :=
@@ -27,39 +26,32 @@ theorem not_entails_not [DecidableEq X]
2726
EntailsInterpret I β F → ¬EntailsInterpret I β (Formula.neg F) :=
2827
fun a a_1 ↦ a_1 a
2928

29+
/-- F is true/valid in I: I ⊨ F -/
3030
@[simp]
3131
def ValidIn [DecidableEq X] (F : Formula sig X) (I : Interpretation sig univ) : Prop :=
3232
∀ (β : Assignment X univ), EntailsInterpret I β F
3333

34-
/- ### Validity / Tautology
35-
> ⊨ F :⇔ A |= F for all A ∈ Σ-Alg
36-
-/
37-
34+
/-- Tautology: ⊨ F -/
3835
@[simp]
3936
def Valid [DecidableEq X] (F : Formula sig X) : Prop :=
4037
∀ (I : Interpretation sig univ) (β : Assignment X univ), Formula.eval I β F
4138

42-
/- ### Entailment
43-
F ⊨ G, if for all A ∈ Σ-Alg and β ∈ X → UA, we have A, β |= F ⇒ A, β |= G
44-
-/
39+
/- ### Entailment -/
4540

41+
/-- Semantic entailment: F ⊨ G -/
4642
@[simp]
4743
def Entails [DecidableEq X] (F G : Formula sig X) : Prop :=
4844
∀ (I : Interpretation sig univ) (β : Assignment X univ),
4945
EntailsInterpret I β F → EntailsInterpret I β G
5046
infix:60 " ⊨ " => Entails
5147

52-
/- ### Equivalence
53-
54-
##### Proposition 3.3.1
55-
> F ⊨ G if and only if F → G is valid`
56-
-/
48+
/-- F ⊨ G ↔ ⊨ F → G -/
5749
theorem entails_iff_imp_valid [inst : DecidableEq X]
5850
(F G : Formula sig X) : @Entails _ _ univ _ F G ↔ @Valid _ _ univ _ (Formula.imp F G) :=
5951
Eq.to_iff rfl
6052

53+
/- ### Satsfiability -/
6154

62-
/- ### Sat -/
6355
@[simp]
6456
def Satisfiable [DecidableEq X] (F : Formula sig X) : Prop :=
6557
∃ (I : Interpretation sig univ) (β : Assignment X univ), EntailsInterpret I β F
@@ -164,13 +156,8 @@ theorem setEntails_iff_union_not_unsat [inst : DecidableEq X]
164156
cases hGornegN I β
165157
aesop
166158

167-
/- lemma term_eval_of_closed {sig : Signature} {X : Variables} [inst : DecidableEq X]
168-
(I : Interpretation sig univ) (F : Formula sig X) (hclosed : Formula.closed F) : -/
169-
170-
/- lemma validIn_of_entails_closed {sig : Signature} {X : Variables} [inst : DecidableEq X]
171-
(I : Interpretation sig univ) (F : Formula sig X) (hclosed : Formula.closed F) :
172-
(∃ (β : Assignment X univ), EntailsInterpret I β F) → ValidIn F I := by -/
173-
159+
/-- This lemma allows us to disregard assignments when considering the entailment of closed
160+
formulas. -/
174161
lemma validIn_of_entails_closed {sig : Signature} {X : Variables} [inst : DecidableEq X]
175162
(I : Interpretation sig univ) (F : Formula sig X) (hclosed : Formula.closed F) :
176163
(∃ (β : Assignment X univ), EntailsInterpret I β F) → ValidIn F I := by
@@ -180,7 +167,9 @@ lemma validIn_of_entails_closed {sig : Signature} {X : Variables} [inst : Decida
180167
rw [EntailsInterpret, heval, ← EntailsInterpret]
181168
exact hγ
182169

183-
/- ### 3.3.4 Substitution Lemma -/
170+
/- ### Lemmas Related to Entailment
171+
In the following section, we prove several lemmas that will be vital in our soundness proof. -/
172+
184173
@[simp]
185174
def Assignment.compose [DecidableEq X] (I : Interpretation sig univ) (β : Assignment X univ)
186175
(σ : Substitution sig X) : Assignment X univ :=
@@ -302,7 +291,6 @@ lemma valid_sub_of_valid {I : Interpretation sig univ} [DecidableEq X] (C : Clau
302291
rw [three_three_five]
303292
exact hvalid
304293

305-
/- ### Lemma 3.3.8 -/
306294
lemma three_three_eight {sig : Signature} {X : Variables} [DecidableEq X] (C : Clause sig X)
307295
(I : Interpretation sig univ) (σ : Substitution sig X) (n m : ℕ)
308296
(xs ys : List X) (hxuniq : xs.Nodup) (hn : xs.length = n)

0 commit comments

Comments
 (0)