2014-12-06 05:46:17 +00:00
|
|
|
|
/-
|
2015-04-24 23:58:50 +00:00
|
|
|
|
Copyright (c) 2014-2015 Microsoft Corporation. All rights reserved.
|
2014-12-06 05:46:17 +00:00
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
2015-04-24 23:58:50 +00:00
|
|
|
|
Authors: Leonardo de Moura, Jeremy Avigad, Floris van Doorn, Jakob von Raumer
|
2014-12-06 05:46:17 +00:00
|
|
|
|
-/
|
2015-02-26 18:19:54 +00:00
|
|
|
|
|
2014-12-06 05:46:17 +00:00
|
|
|
|
prelude
|
2016-02-09 01:07:44 +00:00
|
|
|
|
import init.num init.relation
|
2015-11-21 04:58:06 +00:00
|
|
|
|
open iff
|
2015-04-24 23:58:50 +00:00
|
|
|
|
|
|
|
|
|
-- Empty type
|
|
|
|
|
-- ----------
|
|
|
|
|
|
|
|
|
|
protected definition empty.has_decidable_eq [instance] : decidable_eq empty :=
|
|
|
|
|
take (a b : empty), decidable.inl (!empty.elim a)
|
|
|
|
|
|
|
|
|
|
-- Unit type
|
|
|
|
|
-- ---------
|
|
|
|
|
|
|
|
|
|
namespace unit
|
|
|
|
|
|
|
|
|
|
notation `⋆` := star
|
|
|
|
|
|
|
|
|
|
end unit
|
|
|
|
|
|
|
|
|
|
-- Sigma type
|
|
|
|
|
-- ----------
|
|
|
|
|
|
2015-09-30 23:52:34 +00:00
|
|
|
|
notation `Σ` binders `, ` r:(scoped P, sigma P) := r
|
2015-10-26 22:29:19 +00:00
|
|
|
|
abbreviation dpair [constructor] := @sigma.mk
|
2015-04-24 23:58:50 +00:00
|
|
|
|
namespace sigma
|
2015-09-30 23:52:34 +00:00
|
|
|
|
notation `⟨`:max t:(foldr `, ` (e r, mk e r)) `⟩`:0 := t --input ⟨ ⟩ as \< \>
|
2015-04-24 23:58:50 +00:00
|
|
|
|
|
|
|
|
|
namespace ops
|
|
|
|
|
postfix `.1`:(max+1) := pr1
|
|
|
|
|
postfix `.2`:(max+1) := pr2
|
|
|
|
|
abbreviation pr₁ := @pr1
|
|
|
|
|
abbreviation pr₂ := @pr2
|
|
|
|
|
end ops
|
|
|
|
|
end sigma
|
|
|
|
|
|
|
|
|
|
-- Sum type
|
|
|
|
|
-- --------
|
|
|
|
|
|
|
|
|
|
namespace sum
|
2016-02-16 01:59:38 +00:00
|
|
|
|
infixr + := sum
|
2015-04-24 23:58:50 +00:00
|
|
|
|
namespace low_precedence_plus
|
2015-09-30 23:52:34 +00:00
|
|
|
|
reserve infixr ` + `:25 -- conflicts with notation for addition
|
|
|
|
|
infixr ` + ` := sum
|
2015-04-24 23:58:50 +00:00
|
|
|
|
end low_precedence_plus
|
2015-05-05 21:25:35 +00:00
|
|
|
|
|
|
|
|
|
variables {a b c d : Type}
|
2015-12-08 17:57:55 +00:00
|
|
|
|
|
2015-05-05 21:25:35 +00:00
|
|
|
|
definition sum_of_sum_of_imp_of_imp (H₁ : a ⊎ b) (H₂ : a → c) (H₃ : b → d) : c ⊎ d :=
|
|
|
|
|
sum.rec_on H₁
|
|
|
|
|
(assume Ha : a, sum.inl (H₂ Ha))
|
|
|
|
|
(assume Hb : b, sum.inr (H₃ Hb))
|
|
|
|
|
|
|
|
|
|
definition sum_of_sum_of_imp_left (H₁ : a ⊎ c) (H : a → b) : b ⊎ c :=
|
|
|
|
|
sum.rec_on H₁
|
|
|
|
|
(assume H₂ : a, sum.inl (H H₂))
|
|
|
|
|
(assume H₂ : c, sum.inr H₂)
|
|
|
|
|
|
|
|
|
|
definition sum_of_sum_of_imp_right (H₁ : c ⊎ a) (H : a → b) : c ⊎ b :=
|
|
|
|
|
sum.rec_on H₁
|
|
|
|
|
(assume H₂ : c, sum.inl H₂)
|
|
|
|
|
(assume H₂ : a, sum.inr (H H₂))
|
2015-04-24 23:58:50 +00:00
|
|
|
|
end sum
|
|
|
|
|
|
|
|
|
|
-- Product type
|
|
|
|
|
-- ------------
|
2014-12-06 05:46:17 +00:00
|
|
|
|
|
|
|
|
|
namespace prod
|
2014-12-16 20:10:12 +00:00
|
|
|
|
|
2015-05-02 21:17:50 +00:00
|
|
|
|
-- notation for n-ary tuples
|
2015-09-30 23:52:34 +00:00
|
|
|
|
notation `(` h `, ` t:(foldl `,` (e r, prod.mk r e) h) `)` := t
|
2014-12-16 20:10:12 +00:00
|
|
|
|
|
2015-02-21 00:30:32 +00:00
|
|
|
|
namespace ops
|
|
|
|
|
postfix `.1`:(max+1) := pr1
|
|
|
|
|
postfix `.2`:(max+1) := pr2
|
|
|
|
|
abbreviation pr₁ := @pr1
|
|
|
|
|
abbreviation pr₂ := @pr2
|
|
|
|
|
end ops
|
|
|
|
|
|
2014-12-06 05:46:17 +00:00
|
|
|
|
namespace low_precedence_times
|
2014-12-16 20:10:12 +00:00
|
|
|
|
|
2015-09-30 23:52:34 +00:00
|
|
|
|
reserve infixr ` * `:30 -- conflicts with notation for multiplication
|
|
|
|
|
infixr ` * ` := prod
|
2014-12-16 20:10:12 +00:00
|
|
|
|
|
2014-12-06 05:46:17 +00:00
|
|
|
|
end low_precedence_times
|
|
|
|
|
|
2015-05-02 21:17:50 +00:00
|
|
|
|
open prod.ops
|
2014-12-12 18:17:50 +00:00
|
|
|
|
|
2015-09-22 16:01:55 +00:00
|
|
|
|
definition flip [unfold 3] {A B : Type} (a : A × B) : B × A := pair (pr2 a) (pr1 a)
|
2014-12-06 05:46:17 +00:00
|
|
|
|
|
|
|
|
|
end prod
|