2013-09-02 19:29:21 +00:00
|
|
|
|
Set: pp::colors
|
2013-09-03 17:44:51 +00:00
|
|
|
|
Set: pp::unicode
|
2013-09-01 02:15:48 +00:00
|
|
|
|
Assumed: N
|
|
|
|
|
Assumed: h
|
|
|
|
|
Proved: CongrH
|
2013-09-02 19:29:21 +00:00
|
|
|
|
Set: lean::pp::implicit
|
2013-12-19 21:12:39 +00:00
|
|
|
|
Variable h : N → N → N
|
2013-10-29 23:20:02 +00:00
|
|
|
|
Theorem CongrH {a1 a2 b1 b2 : N} (H1 : eq::explicit N a1 b1) (H2 : eq::explicit N a2 b2) : eq::explicit
|
|
|
|
|
N
|
|
|
|
|
(h a1 a2)
|
|
|
|
|
(h b1 b2) :=
|
2013-09-01 02:15:48 +00:00
|
|
|
|
Congr::explicit
|
|
|
|
|
N
|
2013-09-01 17:34:57 +00:00
|
|
|
|
(λ x : N, N)
|
2013-09-01 02:15:48 +00:00
|
|
|
|
(h a1)
|
|
|
|
|
(h b1)
|
|
|
|
|
a2
|
|
|
|
|
b2
|
2013-09-01 17:34:57 +00:00
|
|
|
|
(Congr::explicit N (λ x : N, N → N) h h a1 b1 (Refl::explicit (N → N → N) h) H1)
|
2013-09-01 02:15:48 +00:00
|
|
|
|
H2
|
2013-09-02 19:29:21 +00:00
|
|
|
|
Set: lean::pp::implicit
|
2013-12-19 21:12:39 +00:00
|
|
|
|
Variable h : N → N → N
|
2013-12-19 20:46:14 +00:00
|
|
|
|
Theorem CongrH {a1 a2 b1 b2 : N} (H1 : a1 = b1) (H2 : a2 = b2) : h a1 a2 = h b1 b2 := Congr (Congr (Refl h) H1) H2
|
2013-09-01 02:15:48 +00:00
|
|
|
|
Proved: Example1
|
2013-09-02 19:29:21 +00:00
|
|
|
|
Set: lean::pp::implicit
|
2013-10-29 23:20:02 +00:00
|
|
|
|
Theorem Example1 (a b c d : N)
|
|
|
|
|
(H : eq::explicit N a b ∧ eq::explicit N b c ∨ eq::explicit N a d ∧ eq::explicit N d c) : eq::explicit
|
|
|
|
|
N
|
|
|
|
|
(h a b)
|
|
|
|
|
(h c b) :=
|
2013-09-01 02:15:48 +00:00
|
|
|
|
DisjCases::explicit
|
2013-10-29 23:20:02 +00:00
|
|
|
|
(eq::explicit N a b ∧ eq::explicit N b c)
|
|
|
|
|
(eq::explicit N a d ∧ eq::explicit N d c)
|
2013-12-19 20:46:14 +00:00
|
|
|
|
(h a b == h c b)
|
2013-09-01 02:15:48 +00:00
|
|
|
|
H
|
2013-10-29 23:20:02 +00:00
|
|
|
|
(λ H1 : eq::explicit N a b ∧ eq::explicit N b c,
|
2013-09-01 02:15:48 +00:00
|
|
|
|
CongrH::explicit
|
|
|
|
|
a
|
|
|
|
|
b
|
|
|
|
|
c
|
|
|
|
|
b
|
|
|
|
|
(Trans::explicit
|
|
|
|
|
N
|
|
|
|
|
a
|
|
|
|
|
b
|
|
|
|
|
c
|
2013-10-29 23:20:02 +00:00
|
|
|
|
(Conjunct1::explicit (eq::explicit N a b) (eq::explicit N b c) H1)
|
|
|
|
|
(Conjunct2::explicit (eq::explicit N a b) (eq::explicit N b c) H1))
|
2013-09-01 02:15:48 +00:00
|
|
|
|
(Refl::explicit N b))
|
2013-10-29 23:20:02 +00:00
|
|
|
|
(λ H1 : eq::explicit N a d ∧ eq::explicit N d c,
|
2013-09-01 02:15:48 +00:00
|
|
|
|
CongrH::explicit
|
|
|
|
|
a
|
|
|
|
|
b
|
|
|
|
|
c
|
|
|
|
|
b
|
|
|
|
|
(Trans::explicit
|
|
|
|
|
N
|
|
|
|
|
a
|
|
|
|
|
d
|
|
|
|
|
c
|
2013-10-29 23:20:02 +00:00
|
|
|
|
(Conjunct1::explicit (eq::explicit N a d) (eq::explicit N d c) H1)
|
|
|
|
|
(Conjunct2::explicit (eq::explicit N a d) (eq::explicit N d c) H1))
|
2013-09-01 02:15:48 +00:00
|
|
|
|
(Refl::explicit N b))
|
|
|
|
|
Proved: Example2
|
2013-09-02 19:29:21 +00:00
|
|
|
|
Set: lean::pp::implicit
|
2013-10-29 23:20:02 +00:00
|
|
|
|
Theorem Example2 (a b c d : N)
|
|
|
|
|
(H : eq::explicit N a b ∧ eq::explicit N b c ∨ eq::explicit N a d ∧ eq::explicit N d c) : eq::explicit
|
|
|
|
|
N
|
|
|
|
|
(h a b)
|
|
|
|
|
(h c b) :=
|
2013-09-01 02:15:48 +00:00
|
|
|
|
DisjCases::explicit
|
2013-10-29 23:20:02 +00:00
|
|
|
|
(eq::explicit N a b ∧ eq::explicit N b c)
|
|
|
|
|
(eq::explicit N a d ∧ eq::explicit N d c)
|
2013-11-29 17:14:54 +00:00
|
|
|
|
(eq::explicit N (h a b) (h c b))
|
2013-09-01 02:15:48 +00:00
|
|
|
|
H
|
2013-10-29 23:20:02 +00:00
|
|
|
|
(λ H1 : eq::explicit N a b ∧ eq::explicit N b c,
|
2013-09-01 02:15:48 +00:00
|
|
|
|
CongrH::explicit
|
|
|
|
|
a
|
|
|
|
|
b
|
|
|
|
|
c
|
|
|
|
|
b
|
|
|
|
|
(Trans::explicit
|
|
|
|
|
N
|
|
|
|
|
a
|
|
|
|
|
b
|
|
|
|
|
c
|
feat(library/elaborator): only expand definitions that are not marked as hidden
The elaborator produces better proof terms. This is particularly important when we have to prove the remaining holes using tactics.
For example, in one of the tests, the elaborator was producing the sub-expression
(λ x : N, if ((λ x::1 : N, if (P a x x::1) ⊥ ⊤) == (λ x : N, ⊤)) ⊥ ⊤)
After, this commit it produces
(λ x : N, ¬ ∀ x::1 : N, ¬ P a x x::1)
The expressions above are definitionally equal, but the second is easier to work with.
Question: do we really need hidden definitions?
Perhaps, we can use only the opaque flag.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-20 10:16:41 +00:00
|
|
|
|
(Conjunct1::explicit (a == b) (eq::explicit N b c) H1)
|
|
|
|
|
(Conjunct2::explicit (eq::explicit N a b) (b == c) H1))
|
2013-09-01 02:15:48 +00:00
|
|
|
|
(Refl::explicit N b))
|
2013-10-29 23:20:02 +00:00
|
|
|
|
(λ H1 : eq::explicit N a d ∧ eq::explicit N d c,
|
2013-09-01 02:15:48 +00:00
|
|
|
|
CongrH::explicit
|
|
|
|
|
a
|
|
|
|
|
b
|
|
|
|
|
c
|
|
|
|
|
b
|
|
|
|
|
(Trans::explicit
|
|
|
|
|
N
|
|
|
|
|
a
|
|
|
|
|
d
|
|
|
|
|
c
|
feat(library/elaborator): only expand definitions that are not marked as hidden
The elaborator produces better proof terms. This is particularly important when we have to prove the remaining holes using tactics.
For example, in one of the tests, the elaborator was producing the sub-expression
(λ x : N, if ((λ x::1 : N, if (P a x x::1) ⊥ ⊤) == (λ x : N, ⊤)) ⊥ ⊤)
After, this commit it produces
(λ x : N, ¬ ∀ x::1 : N, ¬ P a x x::1)
The expressions above are definitionally equal, but the second is easier to work with.
Question: do we really need hidden definitions?
Perhaps, we can use only the opaque flag.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-12-20 10:16:41 +00:00
|
|
|
|
(Conjunct1::explicit (a == d) (eq::explicit N d c) H1)
|
|
|
|
|
(Conjunct2::explicit (eq::explicit N a d) (d == c) H1))
|
2013-09-01 02:15:48 +00:00
|
|
|
|
(Refl::explicit N b))
|
|
|
|
|
Proved: Example3
|
2013-09-02 19:29:21 +00:00
|
|
|
|
Set: lean::pp::implicit
|
2013-12-19 20:46:14 +00:00
|
|
|
|
Theorem Example3 (a b c d e : N) (H : a = b ∧ b = e ∧ b = c ∨ a = d ∧ d = c) : h a b = h c b :=
|
2013-09-01 02:15:48 +00:00
|
|
|
|
DisjCases
|
|
|
|
|
H
|
2013-09-01 17:34:57 +00:00
|
|
|
|
(λ H1 : a = b ∧ b = e ∧ b = c, CongrH (Trans (Conjunct1 H1) (Conjunct2 (Conjunct2 H1))) (Refl b))
|
|
|
|
|
(λ H1 : a = d ∧ d = c, CongrH (Trans (Conjunct1 H1) (Conjunct2 H1)) (Refl b))
|
2013-09-01 02:15:48 +00:00
|
|
|
|
Proved: Example4
|
2013-09-02 19:29:21 +00:00
|
|
|
|
Set: lean::pp::implicit
|
2013-12-19 20:46:14 +00:00
|
|
|
|
Theorem Example4 (a b c d e : N) (H : a = b ∧ b = e ∧ b = c ∨ a = d ∧ d = c) : h a c = h c a :=
|
2013-09-01 02:15:48 +00:00
|
|
|
|
DisjCases
|
|
|
|
|
H
|
2013-09-01 17:34:57 +00:00
|
|
|
|
(λ H1 : a = b ∧ b = e ∧ b = c,
|
|
|
|
|
let AeqC := Trans (Conjunct1 H1) (Conjunct2 (Conjunct2 H1)) in CongrH AeqC (Symm AeqC))
|
|
|
|
|
(λ H1 : a = d ∧ d = c, let AeqC := Trans (Conjunct1 H1) (Conjunct2 H1) in CongrH AeqC (Symm AeqC))
|