@@ -280,6 +280,46 @@ meta structure by_elim_opt :=
280
280
meta def solve_by_elim (opt : by_elim_opt := { }) : tactic unit :=
281
281
solve_by_elim_aux opt.discharger opt.restr_hyp_set opt.max_rep
282
282
283
+ theorem or_iff_not_imp_left {a b} [decidable a] : a ∨ b ↔ (¬ a → b) :=
284
+ ⟨or.resolve_left, λ h, dite _ or.inl (or.inr ∘ h)⟩
285
+
286
+ theorem or_iff_not_imp_right {a b} [decidable b] : a ∨ b ↔ (¬ b → a) :=
287
+ or.comm.trans or_iff_not_imp_left
288
+
289
+ @[trans]
290
+ lemma iff.trans {a b c} (h₁ : a ↔ b) (h₂ : b ↔ c) : a ↔ c :=
291
+ iff.intro
292
+ (assume ha, iff.mp h₂ (iff.mp h₁ ha))
293
+ (assume hc, iff.mpr h₁ (iff.mpr h₂ hc))
294
+
295
+ theorem imp.swap {a b c : Prop } : (a → b → c) ↔ (b → a → c) :=
296
+ ⟨function.swap, function.swap⟩
297
+
298
+ theorem imp_not_comm {a b} : (a → ¬b) ↔ (b → ¬a) :=
299
+ imp.swap
300
+
301
+ theorem not_and_of_not_or_not {a b} (h : ¬ a ∨ ¬ b) : ¬ (a ∧ b)
302
+ | ⟨ha, hb⟩ := or.elim h (absurd ha) (absurd hb)
303
+
304
+ theorem not_and_distrib {a b} [decidable a] : ¬ (a ∧ b) ↔ ¬a ∨ ¬b :=
305
+ ⟨λ h, if ha : a then or.inr (λ hb, h ⟨ha, hb⟩) else or.inl ha, not_and_of_not_or_not⟩
306
+
307
+ theorem not_and_distrib' {a b} [decidable b] : ¬ (a ∧ b) ↔ ¬a ∨ ¬b :=
308
+ ⟨λ h, if hb : b then or.inl (λ ha, h ⟨ha, hb⟩) else or.inr hb, not_and_of_not_or_not⟩
309
+
310
+ theorem not_or_distrib {a b} : ¬ (a ∨ b) ↔ ¬ a ∧ ¬ b :=
311
+ ⟨λ h, ⟨λ ha, h (or.inl ha), λ hb, h (or.inr hb)⟩,
312
+ λ ⟨h₁, h₂⟩ h, or.elim h h₁ h₂⟩
313
+
314
+
315
+ meta def de_morgan_hyps : tactic unit :=
316
+ do hs ← local_context,
317
+ hs.for_each $ λ h,
318
+ replace (some h.local_pp_name) none ``(not_and_distrib'.mp %%h) <|>
319
+ replace (some h.local_pp_name) none ``(not_and_distrib.mp %%h) <|>
320
+ replace (some h.local_pp_name) none ``(not_or_distrib.mp %%h) <|>
321
+ skip
322
+
283
323
/--
284
324
`tautology` breaks down assumptions of the form `_ ∧ _`, `_ ∨ _`, `_ ↔ _` and `∃ _, _`
285
325
and splits a goal of the form `_ ∧ _`, `_ ↔ _` or `∃ _, _` until it can be discharged
@@ -289,12 +329,16 @@ meta def tautology : tactic unit :=
289
329
repeat (do
290
330
gs ← get_goals,
291
331
() <$ tactic.intros;
332
+ de_morgan_hyps,
292
333
casesm (some ()) [``(_ ∧ _),``(_ ∨ _),``(Exists _),``(false)];
293
334
constructor_matching (some ()) [``(_ ∧ _),``(_ ↔ _),``(true)],
335
+ try (refine ``( or_iff_not_imp_left.mpr _)),
336
+ try (refine ``( or_iff_not_imp_right.mpr _)),
294
337
gs' ← get_goals,
295
338
guard (gs ≠ gs') ) ;
296
339
repeat
297
- (reflexivity <|> solve_by_elim <|> constructor_matching none [``(_ ∧ _),``(_ ↔ _),``(Exists _)]) ;
340
+ (reflexivity <|> solve_by_elim <|>
341
+ constructor_matching none [``(_ ∧ _),``(_ ↔ _),``(Exists _)] ) ;
298
342
done
299
343
300
344
/-- Shorter name for the tactic `tautology`. -/
0 commit comments