@@ -86,12 +86,40 @@ object Restriction extends lisa.Main {
8686 val `x ∈ dom(f)` = thenHave(x ∈ dom(f) <=> ∃ (z ∈ f, fst(z) === x)) by Substitute (dom.definition of (R := f))
8787
8888 have(∀ (z, z ∈ (f ↾ A ) <=> (z ∈ f) /\ (fst(z) ∈ A ))) by RightForall (membership)
89- have(x ∈ dom(f ↾ A ) <=> ∃ (z ∈ f, fst(z) ∈ A /\ (fst(z) === x))) by Tableau .from(
89+ val eq1 = have(x ∈ dom(f ↾ A ) <=> ∃ (z ∈ f, fst(z) ∈ A /\ (fst(z) === x))) by Tableau .from(
9090 lastStep,
9191 `x ∈ dom(f)` of (f := f ↾ A )
9292 )
9393
94- sorry
94+ // Forward: ∃(z ∈ f, fst(z) ∈ A ∧ fst(z) = x) |- x ∈ dom(f) ∩ A
95+ have(fst(z) ∈ A |- fst(z) ∈ A ) by Hypothesis
96+ val xInA = thenHave((fst(z) ∈ A , fst(z) === x) |- x ∈ A ) by Congruence
97+
98+ have((z ∈ f, fst(z) === x) |- z ∈ f /\ (fst(z) === x)) by Restate
99+ thenHave((z ∈ f, fst(z) === x) |- ∃ (z, z ∈ f /\ (fst(z) === x))) by RightExists
100+ val xInDomF = thenHave((z ∈ f, fst(z) === x) |- x ∈ dom(f)) by Tautology .fromLastStep(`x ∈ dom(f)`)
101+
102+ have(z ∈ f /\ (fst(z) ∈ A ) /\ (fst(z) === x) |- x ∈ dom(f) /\ (x ∈ A )) by Tautology .from(xInA, xInDomF)
103+ thenHave(∃ (z, z ∈ f /\ (fst(z) ∈ A ) /\ (fst(z) === x)) |- x ∈ dom(f) /\ (x ∈ A )) by LeftExists
104+ val fwd = thenHave(x ∈ dom(f ↾ A ) ==> x ∈ (dom(f) ∩ A )) by Tautology .fromLastStep(
105+ eq1, Intersection .membership of (z := x, x := dom(f), y := A )
106+ )
107+
108+ // Backward: x ∈ dom(f) ∩ A |- ∃(z ∈ f, fst(z) ∈ A ∧ fst(z) = x)
109+ have(x ∈ A |- x ∈ A ) by Hypothesis
110+ val fstInA = thenHave((x ∈ A , fst(z) === x) |- fst(z) ∈ A ) by Congruence
111+
112+ have((z ∈ f, fst(z) === x, fst(z) ∈ A ) |- z ∈ f /\ (fst(z) ∈ A ) /\ (fst(z) === x)) by Restate
113+ thenHave((z ∈ f, fst(z) === x, x ∈ A ) |- z ∈ f /\ (fst(z) ∈ A ) /\ (fst(z) === x)) by Tautology .fromLastStep(fstInA)
114+ thenHave((z ∈ f, fst(z) === x, x ∈ A ) |- ∃ (z, z ∈ f /\ (fst(z) ∈ A ) /\ (fst(z) === x))) by RightExists
115+ thenHave((z ∈ f /\ (fst(z) === x), x ∈ A ) |- ∃ (z, z ∈ f /\ (fst(z) ∈ A ) /\ (fst(z) === x))) by Restate
116+ thenHave((∃ (z, z ∈ f /\ (fst(z) === x)), x ∈ A ) |- ∃ (z, z ∈ f /\ (fst(z) ∈ A ) /\ (fst(z) === x))) by LeftExists
117+ val bwd = thenHave(x ∈ (dom(f) ∩ A ) ==> x ∈ dom(f ↾ A )) by Tautology .fromLastStep(
118+ eq1, `x ∈ dom(f)`, Intersection .membership of (z := x, x := dom(f), y := A )
119+ )
120+
121+ have(x ∈ dom(f ↾ A ) <=> x ∈ (dom(f) ∩ A )) by Tautology .from(fwd, bwd)
122+ thenHave(thesis) by Extensionality
95123 }
96124
97125 /**
@@ -161,19 +189,166 @@ object Restriction extends lisa.Main {
161189 val subsetIsRestriction = Theorem (
162190 (function(f), g ⊆ f) |- (g === f ↾ dom(g))
163191 ) {
164- sorry
192+ assume(function(f))
193+ assume(g ⊆ f)
194+
195+ val gIsFunc = have(function(g)) by Restate .from(BasicTheorems .subset)
196+
197+ // Forward: z ∈ g → z ∈ f↾dom(g)
198+ val fwd = have(z ∈ g |- z ∈ (f ↾ dom(g))) subproof {
199+ assume(z ∈ g)
200+ val zInF = have(z ∈ f) by Tautology .from(Subset .membership of (x := g, y := f, z := z))
201+ have(fst(z) ∈ { fst(z) | z ∈ g }) by Tautology .from(Replacement .map of (x := z, A := g, F := fst))
202+ val fstInDomG = thenHave(fst(z) ∈ dom(g)) by Substitute (dom.definition of (R := g))
203+ have(thesis) by Tautology .from(membership of (A := dom(g)), zInF, fstInDomG)
204+ }
205+
206+ // Backward: z ∈ f↾dom(g) → z ∈ g
207+ val bwd = have(z ∈ (f ↾ dom(g)) |- z ∈ g) subproof {
208+ assume(z ∈ (f ↾ dom(g)))
209+ val zInF = have(z ∈ f) by Tautology .from(membership of (A := dom(g)))
210+ val fstInDomG = have(fst(z) ∈ dom(g)) by Tautology .from(membership of (A := dom(g)))
211+
212+ // z = (fst(z), snd(z)) since f is a function
213+ val zIsPair = have(z === (fst(z), snd(z))) by Tautology .from(BasicTheorems .inversion, zInF)
214+ val pairInF = have((fst(z), snd(z)) ∈ f) by Congruence .from(zInF, zIsPair)
215+ val fstInDomF = have(fst(z) ∈ dom(f)) by Tautology .from(BasicTheorems .domainMembership of (x := fst(z), y := snd(z)), pairInF)
216+
217+ // f(fst(z)) = snd(z)
218+ val fApp = have(f(fst(z)) === snd(z)) by Tautology .from(
219+ BasicTheorems .appDefinition of (x := fst(z), y := snd(z)), fstInDomF, pairInF
220+ )
221+
222+ // g(fst(z)) is defined and (fst(z), g(fst(z))) ∈ g
223+ val gAppInG = have((fst(z), g(fst(z))) ∈ g) by Tautology .from(
224+ BasicTheorems .appDefinition of (f := g, x := fst(z), y := g(fst(z))), gIsFunc, fstInDomG
225+ )
226+
227+ // (fst(z), g(fst(z))) ∈ f since g ⊆ f
228+ val gAppInF = have((fst(z), g(fst(z))) ∈ f) by Tautology .from(
229+ Subset .membership of (x := g, y := f, z := (fst(z), g(fst(z)))), gAppInG
230+ )
231+
232+ // f(fst(z)) = g(fst(z))
233+ val fEqG = have(f(fst(z)) === g(fst(z))) by Tautology .from(
234+ BasicTheorems .appDefinition of (x := fst(z), y := g(fst(z))), fstInDomF, gAppInF
235+ )
236+
237+ // snd(z) = g(fst(z)), so (fst(z), snd(z)) ∈ g
238+ val sndEq = have(snd(z) === g(fst(z))) by Congruence .from(fApp, fEqG)
239+ have((fst(z), snd(z)) ∈ g) by Congruence .from(gAppInG, sndEq)
240+ thenHave(thesis) by Substitute (zIsPair)
241+ }
242+
243+ have(z ∈ g <=> z ∈ (f ↾ dom(g))) by Tautology .from(fwd, bwd)
244+ thenHave(thesis) by Extensionality
165245 }
166246
167247 /**
168- * Theorem --- If `f` and `g` agree on `A`, then `f↾A = g↾A`.
248+ * Theorem --- If `f` and `g` agree on `A`, and `A ⊆ dom(f)` and `A ⊆ dom(g)`, then `f↾A = g↾A`.
169249 */
170250 val extensionality = Theorem (
171- (function(f), function(g), ∀ (x ∈ A , f(x) === g(x))) |- (f ↾ A ) === (g ↾ A )
251+ (function(f), function(g), A ⊆ dom(f), A ⊆ dom(g), ∀ (x ∈ A , f(x) === g(x))) |- (f ↾ A ) === (g ↾ A )
172252 ) {
173253 assume(function(f))
174254 assume(function(g))
255+ assume(A ⊆ dom(f))
256+ assume(A ⊆ dom(g))
175257 assume(∀ (x ∈ A , f(x) === g(x)))
176258
177- sorry
259+ // Forward: z ∈ (f ↾ A) → z ∈ (g ↾ A)
260+ val fwd = have(z ∈ (f ↾ A ) |- z ∈ (g ↾ A )) subproof {
261+ assume(z ∈ (f ↾ A ))
262+
263+ val zInF = have(z ∈ f) by Tautology .from(membership)
264+ val fstInA = have(fst(z) ∈ A ) by Tautology .from(membership)
265+
266+ // z = (fst(z), snd(z)) since function(f) and z ∈ f
267+ val zIsPair = have(z === (fst(z), snd(z))) by Tautology .from(BasicTheorems .inversion, zInF)
268+ val pairInF = have((fst(z), snd(z)) ∈ f) by Congruence .from(zInF, zIsPair)
269+
270+ // fst(z) ∈ dom(f)
271+ val fstInDomF = have(fst(z) ∈ dom(f)) by Tautology .from(
272+ BasicTheorems .domainMembership of (x := fst(z), y := snd(z)), pairInF
273+ )
274+
275+ // f(fst(z)) = snd(z)
276+ val fApp = have(f(fst(z)) === snd(z)) by Tautology .from(
277+ BasicTheorems .appDefinition of (x := fst(z), y := snd(z)), fstInDomF, pairInF
278+ )
279+
280+ // fst(z) ∈ dom(g) from A ⊆ dom(g)
281+ val fstInDomG = have(fst(z) ∈ dom(g)) by Tautology .from(
282+ Subset .membership of (x := A , y := dom(g), z := fst(z)), fstInA
283+ )
284+
285+ // f(fst(z)) = g(fst(z))
286+ have(∀ (x ∈ A , f(x) === g(x))) by Hypothesis
287+ thenHave(fst(z) ∈ A ==> (f(fst(z)) === g(fst(z)))) by InstantiateForall (fst(z))
288+ val fEqG = thenHave(f(fst(z)) === g(fst(z))) by Tautology .fromLastStep(fstInA)
289+
290+ // snd(z) = g(fst(z))
291+ val sndEq = have(snd(z) === g(fst(z))) by Congruence .from(fApp, fEqG)
292+
293+ // (fst(z), g(fst(z))) ∈ g
294+ val gAppInG = have((fst(z), g(fst(z))) ∈ g) by Tautology .from(
295+ BasicTheorems .appDefinition of (f := g, x := fst(z), y := g(fst(z))), fstInDomG
296+ )
297+
298+ // (fst(z), snd(z)) ∈ g
299+ have((fst(z), snd(z)) ∈ g) by Congruence .from(gAppInG, sndEq)
300+ // z ∈ g
301+ thenHave(z ∈ g) by Substitute (zIsPair)
302+
303+ have(thesis) by Tautology .from(lastStep, fstInA, membership of (f := g))
304+ }
305+
306+ // Backward: z ∈ (g ↾ A) → z ∈ (f ↾ A) (symmetric)
307+ val bwd = have(z ∈ (g ↾ A ) |- z ∈ (f ↾ A )) subproof {
308+ assume(z ∈ (g ↾ A ))
309+
310+ val zInG = have(z ∈ g) by Tautology .from(membership of (f := g))
311+ val fstInA = have(fst(z) ∈ A ) by Tautology .from(membership of (f := g))
312+
313+ val zIsPair = have(z === (fst(z), snd(z))) by Tautology .from(BasicTheorems .inversion of (f := g), zInG)
314+ val pairInG = have((fst(z), snd(z)) ∈ g) by Congruence .from(zInG, zIsPair)
315+
316+ val fstInDomG = have(fst(z) ∈ dom(g)) by Tautology .from(
317+ BasicTheorems .domainMembership of (f := g, x := fst(z), y := snd(z)), pairInG
318+ )
319+
320+ // g(fst(z)) = snd(z)
321+ val gApp = have(g(fst(z)) === snd(z)) by Tautology .from(
322+ BasicTheorems .appDefinition of (f := g, x := fst(z), y := snd(z)), fstInDomG, pairInG
323+ )
324+
325+ // fst(z) ∈ dom(f) from A ⊆ dom(f)
326+ val fstInDomF = have(fst(z) ∈ dom(f)) by Tautology .from(
327+ Subset .membership of (x := A , y := dom(f), z := fst(z)), fstInA
328+ )
329+
330+ // f(fst(z)) = g(fst(z))
331+ have(∀ (x ∈ A , f(x) === g(x))) by Hypothesis
332+ thenHave(fst(z) ∈ A ==> (f(fst(z)) === g(fst(z)))) by InstantiateForall (fst(z))
333+ val fEqG = thenHave(f(fst(z)) === g(fst(z))) by Tautology .fromLastStep(fstInA)
334+
335+ // snd(z) = f(fst(z))
336+ val sndEq = have(snd(z) === f(fst(z))) by Congruence .from(gApp, fEqG)
337+
338+ // (fst(z), f(fst(z))) ∈ f
339+ val fAppInF = have((fst(z), f(fst(z))) ∈ f) by Tautology .from(
340+ BasicTheorems .appDefinition of (x := fst(z), y := f(fst(z))), fstInDomF
341+ )
342+
343+ // (fst(z), snd(z)) ∈ f
344+ have((fst(z), snd(z)) ∈ f) by Congruence .from(fAppInF, sndEq)
345+ // z ∈ f
346+ thenHave(z ∈ f) by Substitute (zIsPair)
347+
348+ have(thesis) by Tautology .from(lastStep, fstInA, membership)
349+ }
350+
351+ have(z ∈ (f ↾ A ) <=> z ∈ (g ↾ A )) by Tautology .from(fwd, bwd)
352+ thenHave(thesis) by Extensionality
178353 }
179354}
0 commit comments