(* Diferencia_de_union_e_interseccion.thy -- (s \ t) ∪ (t \ s) = (s ∪ t) \ (s ∩ t). -- José A. Alonso Jiménez -- Sevilla, 18-mayo-2021 ------------------------------------------------------------------ *) (* --------------------------------------------------------------------- Demostrar que (s - t) \ (t - s) = (s \ t) - (s \ t) ------------------------------------------------------------------- *) theory Diferencia_de_union_e_interseccion imports Main begin (* 1 demostración *) lemma "(s - t) \ (t - s) = (s \ t) - (s \ t)" proof (rule equalityI) show "(s - t) \ (t - s) \ (s \ t) - (s \ t)" proof (rule subsetI) fix x assume "x \ (s - t) \ (t - s)" then show "x \ (s \ t) - (s \ t)" proof (rule UnE) assume "x \ s - t" then show "x \ (s \ t) - (s \ t)" proof (rule DiffE) assume "x \ s" assume "x \ t" have "x \ s \ t" using \x \ s\ by (simp only: UnI1) moreover have "x \ s \ t" proof (rule notI) assume "x \ s \ t" then have "x \ t" by (simp only: IntD2) with \x \ t\ show False by (rule notE) qed ultimately show "x \ (s \ t) - (s \ t)" by (rule DiffI) qed next assume "x \ t - s" then show "x \ (s \ t) - (s \ t)" proof (rule DiffE) assume "x \ t" assume "x \ s" have "x \ s \ t" using \x \ t\ by (simp only: UnI2) moreover have "x \ s \ t" proof (rule notI) assume "x \ s \ t" then have "x \ s" by (simp only: IntD1) with \x \ s\ show False by (rule notE) qed ultimately show "x \ (s \ t) - (s \ t)" by (rule DiffI) qed qed qed next show "(s \ t) - (s \ t) \ (s - t) \ (t - s)" proof (rule subsetI) fix x assume "x \ (s \ t) - (s \ t)" then show "x \ (s - t) \ (t - s)" proof (rule DiffE) assume "x \ s \ t" assume "x \ s \ t" note \x \ s \ t\ then show "x \ (s - t) \ (t - s)" proof (rule UnE) assume "x \ s" have "x \ t" proof (rule notI) assume "x \ t" with \x \ s\ have "x \ s \ t" by (rule IntI) with \x \ s \ t\ show False by (rule notE) qed with \x \ s\ have "x \ s - t" by (rule DiffI) then show "x \ (s - t) \ (t - s)" by (simp only: UnI1) next assume "x \ t" have "x \ s" proof (rule notI) assume "x \ s" then have "x \ s \ t" using \x \ t\ by (rule IntI) with \x \ s \ t\ show False by (rule notE) qed with \x \ t\ have "x \ t - s" by (rule DiffI) then show "x \ (s - t) \ (t - s)" by (rule UnI2) qed qed qed qed (* 2 demostración *) lemma "(s - t) \ (t - s) = (s \ t) - (s \ t)" proof show "(s - t) \ (t - s) \ (s \ t) - (s \ t)" proof fix x assume "x \ (s - t) \ (t - s)" then show "x \ (s \ t) - (s \ t)" proof assume "x \ s - t" then show "x \ (s \ t) - (s \ t)" proof assume "x \ s" assume "x \ t" have "x \ s \ t" using \x \ s\ by simp moreover have "x \ s \ t" proof assume "x \ s \ t" then have "x \ t" by simp with \x \ t\ show False by simp qed ultimately show "x \ (s \ t) - (s \ t)" by simp qed next assume "x \ t - s" then show "x \ (s \ t) - (s \ t)" proof assume "x \ t" assume "x \ s" have "x \ s \ t" using \x \ t\ by simp moreover have "x \ s \ t" proof assume "x \ s \ t" then have "x \ s" by simp with \x \ s\ show False by simp qed ultimately show "x \ (s \ t) - (s \ t)" by simp qed qed qed next show "(s \ t) - (s \ t) \ (s - t) \ (t - s)" proof fix x assume "x \ (s \ t) - (s \ t)" then show "x \ (s - t) \ (t - s)" proof assume "x \ s \ t" assume "x \ s \ t" note \x \ s \ t\ then show "x \ (s - t) \ (t - s)" proof assume "x \ s" have "x \ t" proof assume "x \ t" with \x \ s\ have "x \ s \ t" by simp with \x \ s \ t\ show False by simp qed with \x \ s\ have "x \ s - t" by simp then show "x \ (s - t) \ (t - s)" by simp next assume "x \ t" have "x \ s" proof assume "x \ s" then have "x \ s \ t" using \x \ t\ by simp with \x \ s \ t\ show False by simp qed with \x \ t\ have "x \ t - s" by simp then show "x \ (s - t) \ (t - s)" by simp qed qed qed qed (* 3\ demostración *) lemma "(s - t) \ (t - s) = (s \ t) - (s \ t)" proof show "(s - t) \ (t - s) \ (s \ t) - (s \ t)" proof fix x assume "x \ (s - t) \ (t - s)" then show "x \ (s \ t) - (s \ t)" proof assume "x \ s - t" then show "x \ (s \ t) - (s \ t)" by simp next assume "x \ t - s" then show "x \ (s \ t) - (s \ t)" by simp qed qed next show "(s \ t) - (s \ t) \ (s - t) \ (t - s)" proof fix x assume "x \ (s \ t) - (s \ t)" then show "x \ (s - t) \ (t - s)" proof assume "x \ s \ t" assume "x \ s \ t" note \x \ s \ t\ then show "x \ (s - t) \ (t - s)" proof assume "x \ s" then show "x \ (s - t) \ (t - s)" using \x \ s \ t\ by simp next assume "x \ t" then show "x \ (s - t) \ (t - s)" using \x \ s \ t\ by simp qed qed qed qed (* 4\ demostración *) lemma "(s - t) \ (t - s) = (s \ t) - (s \ t)" proof show "(s - t) \ (t - s) \ (s \ t) - (s \ t)" proof fix x assume "x \ (s - t) \ (t - s)" then show "x \ (s \ t) - (s \ t)" by auto qed next show "(s \ t) - (s \ t) \ (s - t) \ (t - s)" proof fix x assume "x \ (s \ t) - (s \ t)" then show "x \ (s - t) \ (t - s)" by auto qed qed (* 5\ demostración *) lemma "(s - t) \ (t - s) = (s \ t) - (s \ t)" proof show "(s - t) \ (t - s) \ (s \ t) - (s \ t)" by auto next show "(s \ t) - (s \ t) \ (s - t) \ (t - s)" by auto qed (* 6\ demostración *) lemma "(s - t) \ (t - s) = (s \ t) - (s \ t)" by auto end