diff --git a/src/builtin/CMakeLists.txt b/src/builtin/CMakeLists.txt index 17822f71b..aaaf08ca9 100644 --- a/src/builtin/CMakeLists.txt +++ b/src/builtin/CMakeLists.txt @@ -95,7 +95,8 @@ add_theory("Real.lean" "${CMAKE_CURRENT_BINARY_DIR}/Int.olean") add_theory("specialfn.lean" "${CMAKE_CURRENT_BINARY_DIR}/Real.olean") add_theory("subtype.lean" "${CMAKE_CURRENT_BINARY_DIR}/kernel.olean") add_theory("optional.lean" "${CMAKE_CURRENT_BINARY_DIR}/subtype.olean") -add_theory("sum.lean" "${CMAKE_CURRENT_BINARY_DIR}/optional.olean") +add_theory("pair.lean" "${CMAKE_CURRENT_BINARY_DIR}/kernel.olean") +add_theory("sum.lean" "${CMAKE_CURRENT_BINARY_DIR}/optional.olean" "${CMAKE_CURRENT_BINARY_DIR}/pair.olean") update_interface("kernel.olean" "kernel" "-n") update_interface("Nat.olean" "library/arith" "-n") diff --git a/src/builtin/obj/pair.olean b/src/builtin/obj/pair.olean new file mode 100644 index 000000000..9c4f04f81 Binary files /dev/null and b/src/builtin/obj/pair.olean differ diff --git a/src/builtin/obj/sum.olean b/src/builtin/obj/sum.olean index 0cc215017..737fd28a9 100644 Binary files a/src/builtin/obj/sum.olean and b/src/builtin/obj/sum.olean differ diff --git a/src/builtin/pair.lean b/src/builtin/pair.lean new file mode 100644 index 000000000..2b82fab4c --- /dev/null +++ b/src/builtin/pair.lean @@ -0,0 +1,10 @@ +-- Copyright (c) 2014 Microsoft Corporation. All rights reserved. +-- Released under Apache 2.0 license as described in the file LICENSE. +-- Author: Leonardo de Moura +definition pair {A : (Type U)} {B : (Type U)} (a : A) (b : B) := tuple a, b +theorem pair_inj1 {A : (Type U)} {B : A → (Type U)} {a b : sig x, B x} (H : a = b) : proj1 a = proj1 b +:= subst (refl (proj1 a)) H +theorem pair_inj2 {A B : (Type U)} {a b : A # B} (H : a = b) : proj2 a = proj2 b +:= subst (refl (proj2 a)) H +theorem pairext_proj {A B : (Type U)} {p : A # B} {a : A} {b : B} (H1 : proj1 p = a) (H2 : proj2 p = b) : p = (pair a b) +:= @pairext A (λ x, B) p (pair a b) H1 (to_heq H2) diff --git a/src/builtin/sum.lean b/src/builtin/sum.lean index d14b25025..8283c6a59 100644 --- a/src/builtin/sum.lean +++ b/src/builtin/sum.lean @@ -2,6 +2,7 @@ -- Released under Apache 2.0 license as described in the file LICENSE. -- Author: Leonardo de Moura import macros +import pair import subtype import optional using subtype @@ -12,15 +13,6 @@ definition sum_pred (A B : (Type U)) := λ p : (optional A) # (optional B), (pro definition sum (A B : (Type U)) := subtype ((optional A) # (optional B)) (sum_pred A B) namespace sum --- TODO: move pair, pair_inj1 and pair_inj2 to separate file -definition pair {A : (Type U)} {B : (Type U)} (a : A) (b : B) := tuple a, b -theorem pair_inj1 {A : (Type U)} {B : A → (Type U)} {a b : sig x, B x} (H : a = b) : proj1 a = proj1 b -:= subst (refl (proj1 a)) H -theorem pair_inj2 {A B : (Type U)} {a b : A # B} (H : a = b) : proj2 a = proj2 b -:= subst (refl (proj2 a)) H -theorem pairext_proj {A B : (Type U)} {p : A # B} {a : A} {b : B} (H1 : proj1 p = a) (H2 : proj2 p = b) : p = (pair a b) -:= @pairext A (λ x, B) p (pair a b) H1 (to_heq H2) - theorem inl_pred {A : (Type U)} (a : A) (B : (Type U)) : sum_pred A B (pair (some a) none) := not_intro (assume N : (some a = none) = (none = (optional::@none B)),