@@ -23,7 +23,6 @@ Classical versions are in the namespace `Classical`.
23
23
-/
24
24
25
25
open Function
26
- attribute [local instance 10] Classical.propDecidable
27
26
28
27
section Miscellany
29
28
@@ -115,10 +114,12 @@ section Propositional
115
114
alias Iff.imp := imp_congr
116
115
117
116
-- This is a duplicate of `Classical.imp_iff_right_iff`. Deprecate?
118
- theorem imp_iff_right_iff {a b : Prop } : (a → b ↔ b) ↔ a ∨ b := Decidable.imp_iff_right_iff
117
+ theorem imp_iff_right_iff {a b : Prop } : (a → b ↔ b) ↔ a ∨ b :=
118
+ open scoped Classical in Decidable.imp_iff_right_iff
119
119
120
120
-- This is a duplicate of `Classical.and_or_imp`. Deprecate?
121
- theorem and_or_imp {a b c : Prop } : a ∧ b ∨ (a → c) ↔ a → b ∨ c := Decidable.and_or_imp
121
+ theorem and_or_imp {a b c : Prop } : a ∧ b ∨ (a → c) ↔ a → b ∨ c :=
122
+ open scoped Classical in Decidable.and_or_imp
122
123
123
124
/-- Provide modus tollens (`mt`) as dot notation for implications. -/
124
125
protected theorem Function.mt {a b : Prop } : (a → b) → ¬b → ¬a := mt
@@ -145,10 +146,11 @@ theorem eq_or_ne {α : Sort*} (x y : α) : x = y ∨ x ≠ y := em <| x = y
145
146
146
147
theorem ne_or_eq {α : Sort *} (x y : α) : x ≠ y ∨ x = y := em' <| x = y
147
148
148
- theorem by_contradiction {p : Prop } : (¬p → False) → p := Decidable.byContradiction
149
+ theorem by_contradiction {p : Prop } : (¬p → False) → p :=
150
+ open scoped Classical in Decidable.byContradiction
149
151
150
152
theorem by_cases {p q : Prop } (hpq : p → q) (hnpq : ¬p → q) : q :=
151
- if hp : p then hpq hp else hnpq hp
153
+ open scoped Classical in if hp : p then hpq hp else hnpq hp
152
154
153
155
alias by_contra := by_contradiction
154
156
@@ -181,15 +183,15 @@ theorem of_not_not {a : Prop} : ¬¬a → a := by_contra
181
183
182
184
theorem not_ne_iff {α : Sort *} {a b : α} : ¬a ≠ b ↔ a = b := not_not
183
185
184
- theorem of_not_imp : ¬(a → b) → a := Decidable.of_not_imp
186
+ theorem of_not_imp : ¬(a → b) → a := open scoped Classical in Decidable.of_not_imp
185
187
186
188
alias Not.decidable_imp_symm := Decidable.not_imp_symm
187
189
188
- theorem Not.imp_symm : (¬a → b) → ¬b → a := Not.decidable_imp_symm
190
+ theorem Not.imp_symm : (¬a → b) → ¬b → a := open scoped Classical in Not.decidable_imp_symm
189
191
190
- theorem not_imp_comm : ¬a → b ↔ ¬b → a := Decidable.not_imp_comm
192
+ theorem not_imp_comm : ¬a → b ↔ ¬b → a := open scoped Classical in Decidable.not_imp_comm
191
193
192
- @[simp] theorem not_imp_self : ¬a → a ↔ a := Decidable.not_imp_self
194
+ @[simp] theorem not_imp_self : ¬a → a ↔ a := open scoped Classical in Decidable.not_imp_self
193
195
194
196
theorem Imp.swap {a b : Sort *} {c : Prop } : a → b → c ↔ b → a → c :=
195
197
⟨fun h x y ↦ h y x, fun h x y ↦ h y x⟩
@@ -257,29 +259,31 @@ theorem Or.imp3 {d e c f : Prop} (had : a → d) (hbe : b → e) (hcf : c → f)
257
259
258
260
export Classical (or_iff_not_imp_left or_iff_not_imp_right)
259
261
260
- theorem not_or_of_imp : (a → b) → ¬a ∨ b := Decidable.not_or_of_imp
262
+ theorem not_or_of_imp : (a → b) → ¬a ∨ b := open scoped Classical in Decidable.not_or_of_imp
261
263
262
264
-- See Note [decidable namespace]
263
265
protected theorem Decidable.or_not_of_imp [Decidable a] (h : a → b) : b ∨ ¬a :=
264
266
dite _ (Or.inl ∘ h) Or.inr
265
267
266
- theorem or_not_of_imp : (a → b) → b ∨ ¬a := Decidable.or_not_of_imp
268
+ theorem or_not_of_imp : (a → b) → b ∨ ¬a := open scoped Classical in Decidable.or_not_of_imp
267
269
268
- theorem imp_iff_not_or : a → b ↔ ¬a ∨ b := Decidable.imp_iff_not_or
270
+ theorem imp_iff_not_or : a → b ↔ ¬a ∨ b := open scoped Classical in Decidable.imp_iff_not_or
269
271
270
- theorem imp_iff_or_not {b a : Prop } : b → a ↔ a ∨ ¬b := Decidable.imp_iff_or_not
272
+ theorem imp_iff_or_not {b a : Prop } : b → a ↔ a ∨ ¬b :=
273
+ open scoped Classical in Decidable.imp_iff_or_not
271
274
272
- theorem not_imp_not : ¬a → ¬b ↔ b → a := Decidable.not_imp_not
275
+ theorem not_imp_not : ¬a → ¬b ↔ b → a := open scoped Classical in Decidable.not_imp_not
273
276
274
277
theorem imp_and_neg_imp_iff (p q : Prop ) : (p → q) ∧ (¬p → q) ↔ q := by simp
275
278
276
279
/-- Provide the reverse of modus tollens (`mt`) as dot notation for implications. -/
277
280
protected theorem Function.mtr : (¬a → ¬b) → b → a := not_imp_not.mp
278
281
279
282
theorem or_congr_left' {c a b : Prop } (h : ¬c → (a ↔ b)) : a ∨ c ↔ b ∨ c :=
280
- Decidable.or_congr_left' h
283
+ open scoped Classical in Decidable.or_congr_left' h
281
284
282
- theorem or_congr_right' {c : Prop } (h : ¬a → (b ↔ c)) : a ∨ b ↔ a ∨ c := Decidable.or_congr_right' h
285
+ theorem or_congr_right' {c : Prop } (h : ¬a → (b ↔ c)) : a ∨ b ↔ a ∨ c :=
286
+ open scoped Classical in Decidable.or_congr_right' h
283
287
284
288
/-! ### Declarations about distributivity -/
285
289
@@ -290,39 +294,44 @@ alias Iff.iff := iff_congr
290
294
-- @[ simp ] -- FIXME simp ignores proof rewrites
291
295
theorem iff_mpr_iff_true_intro {P : Prop } (h : P) : Iff.mpr (iff_true_intro h) True.intro = h := rfl
292
296
293
- theorem imp_or {a b c : Prop } : a → b ∨ c ↔ (a → b) ∨ (a → c) := Decidable.imp_or
297
+ theorem imp_or {a b c : Prop } : a → b ∨ c ↔ (a → b) ∨ (a → c) :=
298
+ open scoped Classical in Decidable.imp_or
294
299
295
- theorem imp_or' {a : Sort *} {b c : Prop } : a → b ∨ c ↔ (a → b) ∨ (a → c) := Decidable.imp_or'
300
+ theorem imp_or' {a : Sort *} {b c : Prop } : a → b ∨ c ↔ (a → b) ∨ (a → c) :=
301
+ open scoped Classical in Decidable.imp_or'
296
302
297
- theorem not_imp : ¬(a → b) ↔ a ∧ ¬b := Decidable.not_imp_iff_and_not
303
+ theorem not_imp : ¬(a → b) ↔ a ∧ ¬b := open scoped Classical in Decidable.not_imp_iff_and_not
298
304
299
- theorem peirce (a b : Prop ) : ((a → b) → a) → a := Decidable.peirce _ _
305
+ theorem peirce (a b : Prop ) : ((a → b) → a) → a := open scoped Classical in Decidable.peirce _ _
300
306
301
- theorem not_iff_not : (¬a ↔ ¬b) ↔ (a ↔ b) := Decidable.not_iff_not
307
+ theorem not_iff_not : (¬a ↔ ¬b) ↔ (a ↔ b) := open scoped Classical in Decidable.not_iff_not
302
308
303
- theorem not_iff_comm : (¬a ↔ b) ↔ (¬b ↔ a) := Decidable.not_iff_comm
309
+ theorem not_iff_comm : (¬a ↔ b) ↔ (¬b ↔ a) := open scoped Classical in Decidable.not_iff_comm
304
310
305
- theorem not_iff : ¬(a ↔ b) ↔ (¬a ↔ b) := Decidable.not_iff
311
+ theorem not_iff : ¬(a ↔ b) ↔ (¬a ↔ b) := open scoped Classical in Decidable.not_iff
306
312
307
- theorem iff_not_comm : (a ↔ ¬b) ↔ (b ↔ ¬a) := Decidable.iff_not_comm
313
+ theorem iff_not_comm : (a ↔ ¬b) ↔ (b ↔ ¬a) := open scoped Classical in Decidable.iff_not_comm
308
314
309
315
theorem iff_iff_and_or_not_and_not : (a ↔ b) ↔ a ∧ b ∨ ¬a ∧ ¬b :=
310
- Decidable.iff_iff_and_or_not_and_not
316
+ open scoped Classical in Decidable.iff_iff_and_or_not_and_not
311
317
312
318
theorem iff_iff_not_or_and_or_not : (a ↔ b) ↔ (¬a ∨ b) ∧ (a ∨ ¬b) :=
313
- Decidable.iff_iff_not_or_and_or_not
319
+ open scoped Classical in Decidable.iff_iff_not_or_and_or_not
314
320
315
- theorem not_and_not_right : ¬(a ∧ ¬b) ↔ a → b := Decidable.not_and_not_right
321
+ theorem not_and_not_right : ¬(a ∧ ¬b) ↔ a → b :=
322
+ open scoped Classical in Decidable.not_and_not_right
316
323
317
324
/-! ### De Morgan's laws -/
318
325
319
326
/-- One of **de Morgan's laws** : the negation of a conjunction is logically equivalent to the
320
327
disjunction of the negations. -/
321
- theorem not_and_or : ¬(a ∧ b) ↔ ¬a ∨ ¬b := Decidable.not_and_iff_not_or_not
328
+ theorem not_and_or : ¬(a ∧ b) ↔ ¬a ∨ ¬b := open scoped Classical in Decidable.not_and_iff_not_or_not
322
329
323
- theorem or_iff_not_and_not : a ∨ b ↔ ¬(¬a ∧ ¬b) := Decidable.or_iff_not_not_and_not
330
+ theorem or_iff_not_and_not : a ∨ b ↔ ¬(¬a ∧ ¬b) :=
331
+ open scoped Classical in Decidable.or_iff_not_not_and_not
324
332
325
- theorem and_iff_not_or_not : a ∧ b ↔ ¬(¬a ∨ ¬b) := Decidable.and_iff_not_not_or_not
333
+ theorem and_iff_not_or_not : a ∧ b ↔ ¬(¬a ∨ ¬b) :=
334
+ open scoped Classical in Decidable.and_iff_not_not_or_not
326
335
327
336
@[simp] theorem not_xor (P Q : Prop ) : ¬Xor' P Q ↔ (P ↔ Q) := by
328
337
simp only [not_and, Xor', not_or, not_not, ← iff_iff_implies_and_implies]
@@ -495,7 +504,8 @@ theorem exists_and_exists_comm {P : α → Prop} {Q : β → Prop} :
495
504
496
505
export Classical (not_forall)
497
506
498
- theorem not_forall_not : (¬∀ x, ¬p x) ↔ ∃ x, p x := Decidable.not_forall_not
507
+ theorem not_forall_not : (¬∀ x, ¬p x) ↔ ∃ x, p x :=
508
+ open scoped Classical in Decidable.not_forall_not
499
509
500
510
export Classical (not_exists_not)
501
511
@@ -507,6 +517,7 @@ lemma exists_or_forall_not (P : α → Prop) : (∃ a, P a) ∨ ∀ a, ¬ P a :=
507
517
508
518
theorem forall_imp_iff_exists_imp {α : Sort *} {p : α → Prop } {b : Prop } [ha : Nonempty α] :
509
519
(∀ x, p x) → b ↔ ∃ x, p x → b := by
520
+ classical
510
521
let ⟨a⟩ := ha
511
522
refine ⟨fun h ↦ not_forall_not.1 fun h' ↦ ?_, fun ⟨x, hx⟩ h ↦ hx (h x)⟩
512
523
exact if hb : b then h' a fun _ ↦ hb else hb <| h fun x ↦ (_root_.not_imp.1 (h' x)).1
@@ -531,7 +542,7 @@ theorem Decidable.and_forall_ne [DecidableEq α] (a : α) {p : α → Prop} :
531
542
simp only [← @forall_eq _ p a, ← forall_and, ← or_imp, Decidable.em, forall_const]
532
543
533
544
theorem and_forall_ne (a : α) : (p a ∧ ∀ b, b ≠ a → p b) ↔ ∀ b, p b :=
534
- Decidable.and_forall_ne a
545
+ open scoped Classical in Decidable.and_forall_ne a
535
546
536
547
theorem Ne.ne_or_ne {x y : α} (z : α) (h : x ≠ y) : x ≠ z ∨ y ≠ z :=
537
548
not_and_or.1 <| mt (and_imp.2 (· ▸ ·)) h.symm
@@ -610,14 +621,14 @@ protected theorem Decidable.forall_or_left {q : Prop} {p : α → Prop} [Decidab
610
621
Or.inr fun x ↦ (h x).resolve_left hq, forall_or_of_or_forall⟩
611
622
612
623
theorem forall_or_left {q} {p : α → Prop } : (∀ x, q ∨ p x) ↔ q ∨ ∀ x, p x :=
613
- Decidable.forall_or_left
624
+ open scoped Classical in Decidable.forall_or_left
614
625
615
626
-- See Note [decidable namespace]
616
627
protected theorem Decidable.forall_or_right {q} {p : α → Prop } [Decidable q] :
617
628
(∀ x, p x ∨ q) ↔ (∀ x, p x) ∨ q := by simp [or_comm, Decidable.forall_or_left]
618
629
619
630
theorem forall_or_right {q} {p : α → Prop } : (∀ x, p x ∨ q) ↔ (∀ x, p x) ∨ q :=
620
- Decidable.forall_or_right
631
+ open scoped Classical in Decidable.forall_or_right
621
632
622
633
theorem Exists.fst {b : Prop } {p : b → Prop } : Exists p → b
623
634
| ⟨h, _⟩ => h
@@ -775,7 +786,8 @@ protected theorem Decidable.not_forall₂ [Decidable (∃ x h, ¬P x h)] [∀ x
775
786
⟨Not.decidable_imp_symm fun nx x h ↦ nx.decidable_imp_symm
776
787
fun h' ↦ ⟨x, h, h'⟩, not_forall₂_of_exists₂_not⟩
777
788
778
- theorem not_forall₂ : (¬∀ x h, P x h) ↔ ∃ x h, ¬P x h := Decidable.not_forall₂
789
+ theorem not_forall₂ : (¬∀ x h, P x h) ↔ ∃ x h, ¬P x h :=
790
+ open scoped Classical in Decidable.not_forall₂
779
791
780
792
theorem forall₂_and : (∀ x h, P x h ∧ Q x h) ↔ (∀ x h, P x h) ∧ ∀ x h, Q x h :=
781
793
Iff.trans (forall_congr' fun _ ↦ forall_and) forall_and
@@ -948,9 +960,9 @@ end ite
948
960
theorem not_beq_of_ne {α : Type *} [BEq α] [LawfulBEq α] {a b : α} (ne : a ≠ b) : ¬(a == b) :=
949
961
fun h => ne (eq_of_beq h)
950
962
951
- theorem beq_eq_decide {α : Type *} [BEq α] [LawfulBEq α] {a b : α} : (a == b) = decide (a = b) := by
952
- rw [← beq_iff_eq (a := a) (b : = b)]
953
- cases a == b <;> simp
963
+ theorem beq_eq_decide {α : Type *} [BEq α] [LawfulBEq α] {a b : α} [Decidable (a = b)] :
964
+ (a == b) = decide (a = b) := by
965
+ by_cases a = b <;> simp_all [beq_iff_eq]
954
966
955
967
@[simp] lemma beq_eq_beq {α β : Type *} [BEq α] [LawfulBEq α] [BEq β] [LawfulBEq β] {a₁ a₂ : α}
956
968
{b₁ b₂ : β} : (a₁ == a₂) = (b₁ == b₂) ↔ (a₁ = a₂ ↔ b₁ = b₂) := by rw [Bool.eq_iff_iff]; simp
@@ -970,4 +982,5 @@ theorem lawful_beq_subsingleton {α : Type*} (inst1 : BEq α) (inst2 : BEq α)
970
982
inst1 = inst2 := by
971
983
apply beq_ext
972
984
intro x y
985
+ classical
973
986
simp only [beq_eq_decide]
0 commit comments