Skip to content

Commit c39b9b7

Browse files
committed
Adjust old proof for generalSoundness_of_soundness
1 parent 714a81d commit c39b9b7

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

InferenceInLean/E_Inference.lean

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,45 @@ the lecture notes. This means that we can show the soundness of an inference sys
6767
showing that all of its inferences are sound. -/
6868
theorem generalSoundness_of_soundness [inst : DecidableEq X]
6969
(Γ : InferenceSystem sig X) : @Soundness _ _ univ _ Γ → @GeneralSoundness _ _ univ _ Γ := by
70-
/- The proof that was here before only worked due to a wrong definition of ClauseSetEntails.
71-
However, the proof was still correct at least for variables being the Empty type. -/
72-
sorry
70+
intro hsound N F hprovable I hvalid β
71+
simp_all only [Soundness, ClauseSetEntails, Clause.eq_1, ValidIn, Assignment.eq_1, EntailsInterpret, Provability]
72+
obtain ⟨proof, hassumption, hconclusion⟩ := hprovable
73+
have hproofsequencetrue : ∀ F ∈ proof.clauses, EntailsInterpret I β F := by
74+
have hindicestrue : ∀ i (hindex : i < proof.clauses.length),
75+
EntailsInterpret I β proof.clauses[i] := by
76+
intro i hlen
77+
induction' i using Nat.case_strong_induction_on with i ih generalizing β
78+
· have hvalid := proof.is_valid 0 hlen
79+
aesop
80+
· have hvalid := proof.is_valid (i + 1) hlen
81+
rcases hvalid with hassump | hconseq
82+
· simp_all only [Soundness, SetEntails, Assignment, EntailsInterpret]
83+
· rcases hconseq with ⟨inference, ⟨hin, ⟨hlast, hcond, hprev⟩⟩⟩
84+
rw [hlast]
85+
have hinfsound := hsound inference hin
86+
apply hinfsound
87+
· exact hcond
88+
· intro inf_form hprem
89+
have hinftrue := hprev inf_form hprem
90+
rcases hinftrue with ⟨j, ⟨hjindex, heq⟩⟩
91+
intro β
92+
have hjtrue := ih j (Nat.le_of_lt_succ hjindex) β (Nat.lt_trans hjindex hlen)
93+
rw [heq]
94+
exact hjtrue
95+
intro F hF
96+
have hfindex : ∃ (i : ℕ) (hindex : i < proof.clauses.length), proof.clauses[i] = F :=
97+
List.mem_iff_getElem.mp hF
98+
aesop
99+
have hlen : proof.clauses.length - 1 < proof.clauses.length := by
100+
have hlennonzero : proof.clauses.length ≠ 0 := by
101+
have hnonempty := proof.clauses_not_empty
102+
simp_all only [List.empty_eq, ne_eq, List.length_eq_zero, not_false_eq_true]
103+
exact Nat.sub_one_lt hlennonzero
104+
have hfconclusion := proof.is_valid (proof.clauses.length - 1) hlen
105+
have hfislast : proof.clauses[proof.clauses.length - 1] = F := by
106+
rw [proof.last_clause_conclusion, hconclusion]
107+
rw [hfislast] at hfconclusion
108+
rcases hfconclusion with hl | hr
109+
· simp_all only [Soundness, SetEntails, Assignment, EntailsInterpret]
110+
· subst hfislast hassumption
111+
simp_all only [Clause.eq_1, EntailsInterpret, List.getElem_mem]

0 commit comments

Comments
 (0)