refactor(library/data/bool): break into pieces to reduce dependencies
This commit is contained in:
parent
e993486301
commit
fd34fd17de
4 changed files with 38 additions and 18 deletions
8
library/data/bool/decl.lean
Normal file
8
library/data/bool/decl.lean
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||||
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
-- Author: Leonardo de Moura
|
||||||
|
import data.unit.decl
|
||||||
|
|
||||||
|
inductive bool : Type :=
|
||||||
|
ff : bool,
|
||||||
|
tt : bool
|
4
library/data/bool/default.lean
Normal file
4
library/data/bool/default.lean
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||||
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
-- Author: Leonardo de Moura
|
||||||
|
import data.bool.decl data.bool.ops data.bool.thms
|
22
library/data/bool/ops.lean
Normal file
22
library/data/bool/ops.lean
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||||
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
-- Author: Leonardo de Moura
|
||||||
|
import general_notation data.bool.decl
|
||||||
|
|
||||||
|
namespace bool
|
||||||
|
definition cond {A : Type} (b : bool) (t e : A) :=
|
||||||
|
rec_on b e t
|
||||||
|
|
||||||
|
definition bor (a b : bool) :=
|
||||||
|
rec_on a (rec_on b ff tt) tt
|
||||||
|
|
||||||
|
notation a || b := bor a b
|
||||||
|
|
||||||
|
definition band (a b : bool) :=
|
||||||
|
rec_on a ff (rec_on b ff tt)
|
||||||
|
|
||||||
|
notation a && b := band a b
|
||||||
|
|
||||||
|
definition bnot (a : bool) :=
|
||||||
|
rec_on a tt ff
|
||||||
|
end bool
|
|
@ -1,17 +1,13 @@
|
||||||
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||||
-- Released under Apache 2.0 license as described in the file LICENSE.
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
-- Author: Leonardo de Moura
|
-- Author: Leonardo de Moura
|
||||||
import general_notation
|
import data.bool.ops
|
||||||
import logic.connectives logic.decidable logic.inhabited
|
import logic.connectives logic.decidable logic.inhabited
|
||||||
|
|
||||||
open eq eq.ops decidable
|
open eq eq.ops decidable
|
||||||
|
|
||||||
inductive bool : Type :=
|
|
||||||
ff : bool,
|
|
||||||
tt : bool
|
|
||||||
namespace bool
|
namespace bool
|
||||||
definition cond {A : Type} (b : bool) (t e : A) :=
|
reducible bor band rec_on
|
||||||
rec_on b e t
|
|
||||||
|
|
||||||
theorem dichotomy (b : bool) : b = ff ∨ b = tt :=
|
theorem dichotomy (b : bool) : b = ff ∨ b = tt :=
|
||||||
cases_on b (or.inl rfl) (or.inr rfl)
|
cases_on b (or.inl rfl) (or.inr rfl)
|
||||||
|
@ -26,12 +22,9 @@ namespace bool
|
||||||
assume H : ff = tt, absurd
|
assume H : ff = tt, absurd
|
||||||
(calc true = cond tt true false : !cond.tt⁻¹
|
(calc true = cond tt true false : !cond.tt⁻¹
|
||||||
... = cond ff true false : {H⁻¹}
|
... = cond ff true false : {H⁻¹}
|
||||||
... = false : !cond.ff)
|
... = false : cond.ff)
|
||||||
true_ne_false
|
true_ne_false
|
||||||
|
|
||||||
definition bor (a b : bool) :=
|
|
||||||
rec_on a (rec_on b ff tt) tt
|
|
||||||
|
|
||||||
theorem bor.tt_left (a : bool) : bor tt a = tt :=
|
theorem bor.tt_left (a : bool) : bor tt a = tt :=
|
||||||
rfl
|
rfl
|
||||||
|
|
||||||
|
@ -69,11 +62,6 @@ namespace bool
|
||||||
or.inr Hb)
|
or.inr Hb)
|
||||||
(assume H, or.inl rfl)
|
(assume H, or.inl rfl)
|
||||||
|
|
||||||
definition band (a b : bool) :=
|
|
||||||
rec_on a ff (rec_on b ff tt)
|
|
||||||
|
|
||||||
notation a && b := band a b
|
|
||||||
|
|
||||||
theorem band.ff_left (a : bool) : ff && a = ff :=
|
theorem band.ff_left (a : bool) : ff && a = ff :=
|
||||||
rfl
|
rfl
|
||||||
|
|
||||||
|
@ -115,9 +103,6 @@ namespace bool
|
||||||
theorem band.eq_tt_elim_right {a b : bool} (H : a && b = tt) : b = tt :=
|
theorem band.eq_tt_elim_right {a b : bool} (H : a && b = tt) : b = tt :=
|
||||||
band.eq_tt_elim_left (!band.comm ⬝ H)
|
band.eq_tt_elim_left (!band.comm ⬝ H)
|
||||||
|
|
||||||
definition bnot (a : bool) :=
|
|
||||||
rec_on a tt ff
|
|
||||||
|
|
||||||
theorem bnot.bnot (a : bool) : bnot (bnot a) = a :=
|
theorem bnot.bnot (a : bool) : bnot (bnot a) = a :=
|
||||||
cases_on a rfl rfl
|
cases_on a rfl rfl
|
||||||
|
|
||||||
|
@ -135,4 +120,5 @@ namespace bool
|
||||||
rec_on a
|
rec_on a
|
||||||
(rec_on b (inl rfl) (inr ff_ne_tt))
|
(rec_on b (inl rfl) (inr ff_ne_tt))
|
||||||
(rec_on b (inr (ne.symm ff_ne_tt)) (inl rfl))
|
(rec_on b (inr (ne.symm ff_ne_tt)) (inl rfl))
|
||||||
|
|
||||||
end bool
|
end bool
|
Loading…
Reference in a new issue