2014-07-13 01:48:40 +00:00
|
|
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
-- Author: Leonardo de Moura
|
2014-10-05 17:50:13 +00:00
|
|
|
import logic.identities logic.decidable
|
|
|
|
import logic.axioms.classical logic.axioms.prop_decidable
|
2014-08-30 03:45:57 +00:00
|
|
|
|
2014-09-03 23:00:38 +00:00
|
|
|
open decidable
|
2014-07-13 01:48:40 +00:00
|
|
|
|
|
|
|
-- Well-founded relation definition
|
|
|
|
-- We are essentially saying that a relation R is well-founded
|
|
|
|
-- if every non-empty "set" P, has a R-minimal element
|
2014-07-29 02:58:57 +00:00
|
|
|
definition wf {A : Type} (R : A → A → Prop) : Prop :=
|
|
|
|
∀P, (∃w, P w) → ∃min, P min ∧ ∀b, R b min → ¬P b
|
2014-07-13 01:48:40 +00:00
|
|
|
|
|
|
|
-- Well-founded induction theorem
|
2014-07-22 16:43:18 +00:00
|
|
|
theorem wf_induction {A : Type} {R : A → A → Prop} {P : A → Prop} (Hwf : wf R) (iH : ∀x, (∀y, R y x → P y) → P x)
|
2014-07-29 02:58:57 +00:00
|
|
|
: ∀x, P x :=
|
|
|
|
by_contradiction (assume N : ¬∀x, P x,
|
2014-08-30 03:45:57 +00:00
|
|
|
-- TODO: when type classes can handle quantifiers, we will not need to give the implicit
|
|
|
|
-- arguments to not_forall_exists
|
|
|
|
obtain (w : A) (Hw : ¬P w), from @not_forall_exists _ _ (take x, _) _ N,
|
2014-07-29 02:58:57 +00:00
|
|
|
-- The main "trick" is to define Q x as ¬P x.
|
|
|
|
-- Since R is well-founded, there must be a R-minimal element r s.t. Q r (which is ¬P r)
|
2014-08-22 01:24:22 +00:00
|
|
|
let Q x := ¬P x in
|
2014-07-29 02:58:57 +00:00
|
|
|
have Qw : ∃w, Q w, from exists_intro w Hw,
|
|
|
|
have Qwf : ∃min, Q min ∧ ∀b, R b min → ¬Q b, from Hwf Q Qw,
|
|
|
|
obtain (r : A) (Hr : Q r ∧ ∀b, R b r → ¬Q b), from Qwf,
|
|
|
|
-- Using the inductive hypothesis iH and Hr, we show P r, and derive the contradiction.
|
|
|
|
have s1 : ∀b, R b r → P b, from
|
|
|
|
take b : A, assume H : R b r,
|
|
|
|
-- We are using Hr to derive ¬¬P b
|
2014-09-05 00:44:53 +00:00
|
|
|
not_not_elim (and.elim_right Hr b H),
|
2014-07-29 02:58:57 +00:00
|
|
|
have s2 : P r, from iH r s1,
|
2014-09-05 00:44:53 +00:00
|
|
|
have s3 : ¬P r, from and.elim_left Hr,
|
2014-07-29 02:58:57 +00:00
|
|
|
absurd s2 s3)
|