chore(*): cleanup lean builtin symbols, replace :: with _
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
25086947fa
commit
57c0006916
125 changed files with 626 additions and 631 deletions
|
@ -35,7 +35,7 @@ Here is an example
|
||||||
:= calc a = b : Ax1
|
:= calc a = b : Ax1
|
||||||
... = c + 1 : Ax2
|
... = c + 1 : Ax2
|
||||||
... = d + 1 : { Ax3 }
|
... = d + 1 : { Ax3 }
|
||||||
... = 1 + d : Nat::add::comm d 1
|
... = 1 + d : Nat::add_comm d 1
|
||||||
... = e : symm Ax4.
|
... = e : symm Ax4.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ proof expression using the given tactic or solver.
|
||||||
|
|
||||||
Even when tactics and solvers are not used, we can still use the elaboration engine to fill
|
Even when tactics and solvers are not used, we can still use the elaboration engine to fill
|
||||||
gaps in our calculational proofs. In the previous examples, we can use `_` as arguments for the
|
gaps in our calculational proofs. In the previous examples, we can use `_` as arguments for the
|
||||||
`Nat::add::comm` theorem. The Lean elaboration engine will infer `d` and `1` for us.
|
`Nat::add_comm` theorem. The Lean elaboration engine will infer `d` and `1` for us.
|
||||||
Here is the same example using placeholders.
|
Here is the same example using placeholders.
|
||||||
|
|
||||||
```lean
|
```lean
|
||||||
|
@ -53,7 +53,7 @@ Here is the same example using placeholders.
|
||||||
:= calc a = b : Ax1
|
:= calc a = b : Ax1
|
||||||
... = c + 1 : Ax2
|
... = c + 1 : Ax2
|
||||||
... = d + 1 : { Ax3 }
|
... = d + 1 : { Ax3 }
|
||||||
... = 1 + d : Nat::add::comm _ _
|
... = 1 + d : Nat::add_comm _ _
|
||||||
... = e : symm Ax4.
|
... = e : symm Ax4.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ Here is an example.
|
||||||
theorem T2 (a b c : Nat) (H1 : a = b) (H2 : b = c + 1) : a ≠ 0
|
theorem T2 (a b c : Nat) (H1 : a = b) (H2 : b = c + 1) : a ≠ 0
|
||||||
:= calc a = b : H1
|
:= calc a = b : H1
|
||||||
... = c + 1 : H2
|
... = c + 1 : H2
|
||||||
... ≠ 0 : Nat::succ::nz _.
|
... ≠ 0 : Nat::succ_nz _.
|
||||||
```
|
```
|
||||||
|
|
||||||
The Lean `let` construct can also be used to build calculational-like proofs.
|
The Lean `let` construct can also be used to build calculational-like proofs.
|
||||||
|
|
|
@ -88,16 +88,16 @@ infix 50 = : eq
|
||||||
```
|
```
|
||||||
|
|
||||||
The curly braces indicate that the first argument of `eq` is implicit. The symbol `=` is just a syntax sugar for `eq`.
|
The curly braces indicate that the first argument of `eq` is implicit. The symbol `=` is just a syntax sugar for `eq`.
|
||||||
In the following example, we use the `set::option` command to force Lean to display implicit arguments and
|
In the following example, we use the `set_option` command to force Lean to display implicit arguments and
|
||||||
disable notation when pretty printing expressions.
|
disable notation when pretty printing expressions.
|
||||||
|
|
||||||
```lean
|
```lean
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
check 1 = 2
|
check 1 = 2
|
||||||
|
|
||||||
-- restore default configuration
|
-- restore default configuration
|
||||||
set::option pp::implicit false
|
set_option pp::implicit false
|
||||||
set::option pp::notation true
|
set_option pp::notation true
|
||||||
check 1 = 2
|
check 1 = 2
|
||||||
```
|
```
|
||||||
|
|
|
@ -76,7 +76,7 @@ In the following example we prove that `double x = 2 * x`
|
||||||
```lean
|
```lean
|
||||||
theorem double_x_eq_2x (x : Nat) : double x = 2 * x :=
|
theorem double_x_eq_2x (x : Nat) : double x = 2 * x :=
|
||||||
calc double x = x + x : refl (double x)
|
calc double x = x + x : refl (double x)
|
||||||
... = 1*x + 1*x : { symm (mul::onel x) }
|
... = 1*x + 1*x : { symm (mul_onel x) }
|
||||||
... = (1 + 1)*x : symm (distributel 1 1 x)
|
... = (1 + 1)*x : symm (distributel 1 1 x)
|
||||||
... = 2 * x : { refl (1 + 1) }
|
... = 2 * x : { refl (1 + 1) }
|
||||||
```
|
```
|
||||||
|
@ -84,7 +84,7 @@ In the following example we prove that `double x = 2 * x`
|
||||||
In the example above, we provided the proof manually using a calculational proof style.
|
In the example above, we provided the proof manually using a calculational proof style.
|
||||||
The terms after `:` are proof terms. They justify the equalities in the left-hand-side.
|
The terms after `:` are proof terms. They justify the equalities in the left-hand-side.
|
||||||
The proof term `refl (double x)` produces a proof for `t = s` where `t` and `s` have the same
|
The proof term `refl (double x)` produces a proof for `t = s` where `t` and `s` have the same
|
||||||
normal form of `(double x)`. The proof term `{ symm (mul::onel x) }` is a justification for
|
normal form of `(double x)`. The proof term `{ symm (mul_onel x) }` is a justification for
|
||||||
the equality `x = 1*x`. The curly braces instruct Lean to replace `x` with `1*x`.
|
the equality `x = 1*x`. The curly braces instruct Lean to replace `x` with `1*x`.
|
||||||
Similarly `{ symm (distributel 1 1 x) }` is a proof for `1*x + 1*x = (1 + 1)*x`.
|
Similarly `{ symm (distributel 1 1 x) }` is a proof for `1*x + 1*x = (1 + 1)*x`.
|
||||||
The exact semantics of these expressions is not important at this point.
|
The exact semantics of these expressions is not important at this point.
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
(define-generic-mode
|
(define-generic-mode
|
||||||
'lean-mode ;; name of the mode to create
|
'lean-mode ;; name of the mode to create
|
||||||
'("--") ;; comments start with
|
'("--") ;; comments start with
|
||||||
'("import" "definition" "variable" "variables" "print" "axiom" "theorem" "universe" "alias" "help" "set::option" "set::opaque" "environment" "options" "infix" "infixl" "infixr" "notation" "eval" "check" "exit" "coercion" "end" "using" "namespace" "builtin" "scope" "pop::scope") ;; some keywords
|
'("import" "definition" "variable" "variables" "print" "axiom" "theorem" "universe" "alias" "help" "set_option" "set_opaque" "environment" "options" "infix" "infixl" "infixr" "notation" "eval" "check" "exit" "coercion" "end" "using" "namespace" "builtin" "scope" "pop_scope") ;; some keywords
|
||||||
'(("\\<\\(Bool\\|Int\\|Nat\\|Real\\|Type\\|TypeU\\|ℕ\\|ℤ\\)\\>" . 'font-lock-type-face)
|
'(("\\<\\(Bool\\|Int\\|Nat\\|Real\\|Type\\|TypeU\\|ℕ\\|ℤ\\)\\>" . 'font-lock-type-face)
|
||||||
("\\<\\(calc\\|have\\|in\\|let\\)\\>" . font-lock-keyword-face)
|
("\\<\\(calc\\|have\\|in\\|let\\)\\>" . font-lock-keyword-face)
|
||||||
("\"[^\"]*\"" . 'font-lock-string-face)
|
("\"[^\"]*\"" . 'font-lock-string-face)
|
||||||
|
|
|
@ -14,7 +14,7 @@ definition odd (a : Nat) := ∃ b, a = 2*b + 1
|
||||||
-- It is syntax sugar for existential elimination.
|
-- It is syntax sugar for existential elimination.
|
||||||
-- It expands to
|
-- It expands to
|
||||||
--
|
--
|
||||||
-- exists::elim [expr]_1 (fun [binding], [expr]_2)
|
-- exists_elim [expr]_1 (fun [binding], [expr]_2)
|
||||||
--
|
--
|
||||||
-- It is defined in the file macros.lua.
|
-- It is defined in the file macros.lua.
|
||||||
--
|
--
|
||||||
|
@ -32,12 +32,12 @@ definition odd (a : Nat) := ∃ b, a = 2*b + 1
|
||||||
theorem EvenPlusEven {a b : Nat} (H1 : even a) (H2 : even b) : even (a + b)
|
theorem EvenPlusEven {a b : Nat} (H1 : even a) (H2 : even b) : even (a + b)
|
||||||
:= obtain (w1 : Nat) (Hw1 : a = 2*w1), from H1,
|
:= obtain (w1 : Nat) (Hw1 : a = 2*w1), from H1,
|
||||||
obtain (w2 : Nat) (Hw2 : b = 2*w2), from H2,
|
obtain (w2 : Nat) (Hw2 : b = 2*w2), from H2,
|
||||||
exists::intro (w1 + w2)
|
exists_intro (w1 + w2)
|
||||||
(calc a + b = 2*w1 + b : { Hw1 }
|
(calc a + b = 2*w1 + b : { Hw1 }
|
||||||
... = 2*w1 + 2*w2 : { Hw2 }
|
... = 2*w1 + 2*w2 : { Hw2 }
|
||||||
... = 2*(w1 + w2) : symm (distributer 2 w1 w2))
|
... = 2*(w1 + w2) : symm (distributer 2 w1 w2))
|
||||||
|
|
||||||
-- In the following example, we omit the arguments for add::assoc, refl and distribute.
|
-- In the following example, we omit the arguments for add_assoc, refl and distribute.
|
||||||
-- Lean can infer them automatically.
|
-- Lean can infer them automatically.
|
||||||
--
|
--
|
||||||
-- refl is the reflexivity proof. (refl a) is a proof that two
|
-- refl is the reflexivity proof. (refl a) is a proof that two
|
||||||
|
@ -52,9 +52,9 @@ theorem EvenPlusEven {a b : Nat} (H1 : even a) (H2 : even b) : even (a + b)
|
||||||
-- any theorems such as + associativity.
|
-- any theorems such as + associativity.
|
||||||
theorem OddPlusOne {a : Nat} (H : odd a) : even (a + 1)
|
theorem OddPlusOne {a : Nat} (H : odd a) : even (a + 1)
|
||||||
:= obtain (w : Nat) (Hw : a = 2*w + 1), from H,
|
:= obtain (w : Nat) (Hw : a = 2*w + 1), from H,
|
||||||
exists::intro (w + 1)
|
exists_intro (w + 1)
|
||||||
(calc a + 1 = 2*w + 1 + 1 : { Hw }
|
(calc a + 1 = 2*w + 1 + 1 : { Hw }
|
||||||
... = 2*w + (1 + 1) : symm (add::assoc _ _ _)
|
... = 2*w + (1 + 1) : symm (add_assoc _ _ _)
|
||||||
... = 2*w + 2*1 : refl _
|
... = 2*w + 2*1 : refl _
|
||||||
... = 2*(w + 1) : symm (distributer _ _ _))
|
... = 2*(w + 1) : symm (distributer _ _ _))
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ print environment 2
|
||||||
|
|
||||||
-- By default, Lean does not display implicit arguments.
|
-- By default, Lean does not display implicit arguments.
|
||||||
-- The following command will force it to display them.
|
-- The following command will force it to display them.
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
|
|
||||||
print environment 2
|
print environment 2
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ axiom H2 : b = e
|
||||||
|
|
||||||
-- Proof that (h a b) = (h c e)
|
-- Proof that (h a b) = (h c e)
|
||||||
theorem T1 : (h a b) = (h c e) :=
|
theorem T1 : (h a b) = (h c e) :=
|
||||||
or::elim H1
|
or_elim H1
|
||||||
(λ C1, congrh ((and::eliml C1) ⋈ (and::elimr C1)) H2)
|
(λ C1, congrh ((and_eliml C1) ⋈ (and_elimr C1)) H2)
|
||||||
(λ C2, congrh ((and::elimr C2) ⋈ (and::eliml C2)) H2)
|
(λ C2, congrh ((and_elimr C2) ⋈ (and_eliml C2)) H2)
|
||||||
|
|
||||||
-- We can use theorem T1 to prove other theorems
|
-- We can use theorem T1 to prove other theorems
|
||||||
theorem T2 : (h a (h a b)) = (h a (h c e)) :=
|
theorem T2 : (h a (h a b)) = (h a (h c e)) :=
|
||||||
|
@ -30,6 +30,6 @@ theorem T2 : (h a (h a b)) = (h a (h c e)) :=
|
||||||
print environment 2
|
print environment 2
|
||||||
|
|
||||||
-- print implicit arguments
|
-- print implicit arguments
|
||||||
set::option lean::pp::implicit true
|
set_option lean::pp::implicit true
|
||||||
set::option pp::width 150
|
set_option pp::width 150
|
||||||
print environment 2
|
print environment 2
|
||||||
|
|
|
@ -2,11 +2,11 @@ import macros.
|
||||||
|
|
||||||
theorem simple (p q r : Bool) : (p → q) ∧ (q → r) → p → r
|
theorem simple (p q r : Bool) : (p → q) ∧ (q → r) → p → r
|
||||||
:= λ H_pq_qr H_p,
|
:= λ H_pq_qr H_p,
|
||||||
let P_pq := and::eliml H_pq_qr,
|
let P_pq := and_eliml H_pq_qr,
|
||||||
P_qr := and::elimr H_pq_qr
|
P_qr := and_elimr H_pq_qr
|
||||||
in P_qr (P_pq H_p)
|
in P_qr (P_pq H_p)
|
||||||
|
|
||||||
set::option pp::implicit true.
|
set_option pp::implicit true.
|
||||||
print environment 1.
|
print environment 1.
|
||||||
|
|
||||||
theorem simple2 (a b c : Bool) : (a → b → c) → (a → b) → a → c
|
theorem simple2 (a b c : Bool) : (a → b → c) → (a → b) → a → c
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import macros.
|
import macros.
|
||||||
|
|
||||||
theorem and_comm (a b : Bool) : (a ∧ b) → (b ∧ a)
|
theorem my_and_comm (a b : Bool) : (a ∧ b) → (b ∧ a)
|
||||||
:= λ H_ab, and::intro (and::elimr H_ab) (and::eliml H_ab).
|
:= λ H_ab, and_intro (and_elimr H_ab) (and_eliml H_ab).
|
||||||
|
|
||||||
theorem or_comm (a b : Bool) : (a ∨ b) → (b ∨ a)
|
theorem my_or_comm (a b : Bool) : (a ∨ b) → (b ∨ a)
|
||||||
:= λ H_ab,
|
:= λ H_ab,
|
||||||
or::elim H_ab
|
or_elim H_ab
|
||||||
(λ H_a, or::intror b H_a)
|
(λ H_a, or_intror b H_a)
|
||||||
(λ H_b, or::introl H_b a).
|
(λ H_b, or_introl H_b a).
|
||||||
|
|
||||||
-- (em a) is the excluded middle a ∨ ¬a
|
-- (em a) is the excluded middle a ∨ ¬a
|
||||||
-- (mt H H_na) is Modus Tollens with
|
-- (mt H H_na) is Modus Tollens with
|
||||||
|
@ -16,13 +16,13 @@ theorem or_comm (a b : Bool) : (a ∨ b) → (b ∨ a)
|
||||||
-- produces
|
-- produces
|
||||||
-- ¬(a → b)
|
-- ¬(a → b)
|
||||||
--
|
--
|
||||||
-- not::imp::eliml applied to
|
-- not_imp_eliml applied to
|
||||||
-- (MT H H_na) : ¬(a → b)
|
-- (MT H H_na) : ¬(a → b)
|
||||||
-- produces
|
-- produces
|
||||||
-- a
|
-- a
|
||||||
theorem pierce (a b : Bool) : ((a → b) → a) → a
|
theorem pierce (a b : Bool) : ((a → b) → a) → a
|
||||||
:= λ H, or::elim (em a)
|
:= λ H, or_elim (em a)
|
||||||
(λ H_a, H_a)
|
(λ H_a, H_a)
|
||||||
(λ H_na, not::imp::eliml (mt H H_na)).
|
(λ H_na, not_imp_eliml (mt H H_na)).
|
||||||
|
|
||||||
print environment 3.
|
print environment 3.
|
|
@ -12,7 +12,7 @@ scope
|
||||||
let L1 : R w x := Symm x w H
|
let L1 : R w x := Symm x w H
|
||||||
in Trans x w x H L1
|
in Trans x w x H L1
|
||||||
|
|
||||||
pop::scope
|
pop_scope
|
||||||
|
|
||||||
scope
|
scope
|
||||||
-- Same example again.
|
-- Same example again.
|
||||||
|
|
|
@ -8,17 +8,17 @@ infix 60 ∈ : element
|
||||||
definition subset {A : Type} (s1 : Set A) (s2 : Set A) := ∀ x, x ∈ s1 → x ∈ s2
|
definition subset {A : Type} (s1 : Set A) (s2 : Set A) := ∀ x, x ∈ s1 → x ∈ s2
|
||||||
infix 50 ⊆ : subset
|
infix 50 ⊆ : subset
|
||||||
|
|
||||||
theorem subset::trans {A : Type} {s1 s2 s3 : Set A} (H1 : s1 ⊆ s2) (H2 : s2 ⊆ s3) : s1 ⊆ s3
|
theorem subset_trans {A : Type} {s1 s2 s3 : Set A} (H1 : s1 ⊆ s2) (H2 : s2 ⊆ s3) : s1 ⊆ s3
|
||||||
:= λ (x : A) (Hin : x ∈ s1),
|
:= λ (x : A) (Hin : x ∈ s1),
|
||||||
have x ∈ s3 :
|
have x ∈ s3 :
|
||||||
let L1 : x ∈ s2 := H1 x Hin
|
let L1 : x ∈ s2 := H1 x Hin
|
||||||
in H2 x L1
|
in H2 x L1
|
||||||
|
|
||||||
theorem subset::ext {A : Type} {s1 s2 : Set A} (H : ∀ x, x ∈ s1 = x ∈ s2) : s1 = s2
|
theorem subset_ext {A : Type} {s1 s2 : Set A} (H : ∀ x, x ∈ s1 = x ∈ s2) : s1 = s2
|
||||||
:= funext H
|
:= funext H
|
||||||
|
|
||||||
theorem subset::antisym {A : Type} {s1 s2 : Set A} (H1 : s1 ⊆ s2) (H2 : s2 ⊆ s1) : s1 = s2
|
theorem subset_antisym {A : Type} {s1 s2 : Set A} (H1 : s1 ⊆ s2) (H2 : s2 ⊆ s1) : s1 = s2
|
||||||
:= subset::ext (have (∀ x, x ∈ s1 = x ∈ s2) :
|
:= subset_ext (have (∀ x, x ∈ s1 = x ∈ s2) :
|
||||||
λ x, have x ∈ s1 = x ∈ s2 :
|
λ x, have x ∈ s1 = x ∈ s2 :
|
||||||
boolext (have x ∈ s1 → x ∈ s2 : H1 x)
|
boolext (have x ∈ s1 → x ∈ s2 : H1 x)
|
||||||
(have x ∈ s2 → x ∈ s1 : H2 x))
|
(have x ∈ s2 → x ∈ s1 : H2 x))
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
local pb = s:proof_builder()
|
local pb = s:proof_builder()
|
||||||
local new_pb =
|
local new_pb =
|
||||||
function(m, a)
|
function(m, a)
|
||||||
local Conj = Const({"and", "intro"})
|
local Conj = Const("and_intro")
|
||||||
local new_m = proof_map(m) -- Copy proof map m
|
local new_m = proof_map(m) -- Copy proof map m
|
||||||
for _, p in ipairs(proof_info) do
|
for _, p in ipairs(proof_info) do
|
||||||
local n = p[1] -- n is the name of the goal splitted by this tactic
|
local n = p[1] -- n is the name of the goal splitted by this tactic
|
||||||
|
|
|
@ -46,14 +46,14 @@ infix 50 | : divides
|
||||||
definition abs (a : Int) : Int := if (0 ≤ a) a (- a)
|
definition abs (a : Int) : Int := if (0 ≤ a) a (- a)
|
||||||
notation 55 | _ | : abs
|
notation 55 | _ | : abs
|
||||||
|
|
||||||
set::opaque sub true
|
set_opaque sub true
|
||||||
set::opaque neg true
|
set_opaque neg true
|
||||||
set::opaque mod true
|
set_opaque mod true
|
||||||
set::opaque divides true
|
set_opaque divides true
|
||||||
set::opaque abs true
|
set_opaque abs true
|
||||||
set::opaque ge true
|
set_opaque ge true
|
||||||
set::opaque lt true
|
set_opaque lt true
|
||||||
set::opaque gt true
|
set_opaque gt true
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace Nat
|
namespace Nat
|
||||||
|
@ -63,6 +63,6 @@ infixl 65 - : sub
|
||||||
definition neg (a : Nat) : Int := - (nat_to_int a)
|
definition neg (a : Nat) : Int := - (nat_to_int a)
|
||||||
notation 75 - _ : neg
|
notation 75 - _ : neg
|
||||||
|
|
||||||
set::opaque sub true
|
set_opaque sub true
|
||||||
set::opaque neg true
|
set_opaque neg true
|
||||||
end
|
end
|
|
@ -30,219 +30,219 @@ infix 50 > : gt
|
||||||
definition id (a : Nat) := a
|
definition id (a : Nat) := a
|
||||||
notation 55 | _ | : id
|
notation 55 | _ | : id
|
||||||
|
|
||||||
axiom succ::nz (a : Nat) : a + 1 ≠ 0
|
axiom succ_nz (a : Nat) : a + 1 ≠ 0
|
||||||
axiom succ::inj {a b : Nat} (H : a + 1 = b + 1) : a = b
|
axiom succ_inj {a b : Nat} (H : a + 1 = b + 1) : a = b
|
||||||
axiom add::zeror (a : Nat) : a + 0 = a
|
axiom add_zeror (a : Nat) : a + 0 = a
|
||||||
axiom add::succr (a b : Nat) : a + (b + 1) = (a + b) + 1
|
axiom add_succr (a b : Nat) : a + (b + 1) = (a + b) + 1
|
||||||
axiom mul::zeror (a : Nat) : a * 0 = 0
|
axiom mul_zeror (a : Nat) : a * 0 = 0
|
||||||
axiom mul::succr (a b : Nat) : a * (b + 1) = a * b + a
|
axiom mul_succr (a b : Nat) : a * (b + 1) = a * b + a
|
||||||
axiom le::def (a b : Nat) : a ≤ b = ∃ c, a + c = b
|
axiom le_def (a b : Nat) : a ≤ b = ∃ c, a + c = b
|
||||||
axiom induction {P : Nat → Bool} (a : Nat) (H1 : P 0) (H2 : ∀ (n : Nat) (iH : P n), P (n + 1)) : P a
|
axiom induction {P : Nat → Bool} (a : Nat) (H1 : P 0) (H2 : ∀ (n : Nat) (iH : P n), P (n + 1)) : P a
|
||||||
|
|
||||||
theorem pred::nz {a : Nat} : a ≠ 0 → ∃ b, b + 1 = a
|
theorem pred_nz {a : Nat} : a ≠ 0 → ∃ b, b + 1 = a
|
||||||
:= induction a
|
:= induction a
|
||||||
(λ H : 0 ≠ 0, false::elim (∃ b, b + 1 = 0) H)
|
(λ H : 0 ≠ 0, false_elim (∃ b, b + 1 = 0) H)
|
||||||
(λ (n : Nat) (iH : n ≠ 0 → ∃ b, b + 1 = n) (H : n + 1 ≠ 0),
|
(λ (n : Nat) (iH : n ≠ 0 → ∃ b, b + 1 = n) (H : n + 1 ≠ 0),
|
||||||
or::elim (em (n = 0))
|
or_elim (em (n = 0))
|
||||||
(λ Heq0 : n = 0, exists::intro 0 (calc 0 + 1 = n + 1 : { symm Heq0 }))
|
(λ Heq0 : n = 0, exists_intro 0 (calc 0 + 1 = n + 1 : { symm Heq0 }))
|
||||||
(λ Hne0 : n ≠ 0,
|
(λ Hne0 : n ≠ 0,
|
||||||
obtain (w : Nat) (Hw : w + 1 = n), from (iH Hne0),
|
obtain (w : Nat) (Hw : w + 1 = n), from (iH Hne0),
|
||||||
exists::intro (w + 1) (calc w + 1 + 1 = n + 1 : { Hw })))
|
exists_intro (w + 1) (calc w + 1 + 1 = n + 1 : { Hw })))
|
||||||
|
|
||||||
theorem discriminate {B : Bool} {a : Nat} (H1: a = 0 → B) (H2 : ∀ n, a = n + 1 → B) : B
|
theorem discriminate {B : Bool} {a : Nat} (H1: a = 0 → B) (H2 : ∀ n, a = n + 1 → B) : B
|
||||||
:= or::elim (em (a = 0))
|
:= or_elim (em (a = 0))
|
||||||
(λ Heq0 : a = 0, H1 Heq0)
|
(λ Heq0 : a = 0, H1 Heq0)
|
||||||
(λ Hne0 : a ≠ 0, obtain (w : Nat) (Hw : w + 1 = a), from (pred::nz Hne0),
|
(λ Hne0 : a ≠ 0, obtain (w : Nat) (Hw : w + 1 = a), from (pred_nz Hne0),
|
||||||
H2 w (symm Hw))
|
H2 w (symm Hw))
|
||||||
|
|
||||||
theorem add::zerol (a : Nat) : 0 + a = a
|
theorem add_zerol (a : Nat) : 0 + a = a
|
||||||
:= induction a
|
:= induction a
|
||||||
(have 0 + 0 = 0 : trivial)
|
(have 0 + 0 = 0 : trivial)
|
||||||
(λ (n : Nat) (iH : 0 + n = n),
|
(λ (n : Nat) (iH : 0 + n = n),
|
||||||
calc 0 + (n + 1) = (0 + n) + 1 : add::succr 0 n
|
calc 0 + (n + 1) = (0 + n) + 1 : add_succr 0 n
|
||||||
... = n + 1 : { iH })
|
... = n + 1 : { iH })
|
||||||
|
|
||||||
theorem add::succl (a b : Nat) : (a + 1) + b = (a + b) + 1
|
theorem add_succl (a b : Nat) : (a + 1) + b = (a + b) + 1
|
||||||
:= induction b
|
:= induction b
|
||||||
(calc (a + 1) + 0 = a + 1 : add::zeror (a + 1)
|
(calc (a + 1) + 0 = a + 1 : add_zeror (a + 1)
|
||||||
... = (a + 0) + 1 : { symm (add::zeror a) })
|
... = (a + 0) + 1 : { symm (add_zeror a) })
|
||||||
(λ (n : Nat) (iH : (a + 1) + n = (a + n) + 1),
|
(λ (n : Nat) (iH : (a + 1) + n = (a + n) + 1),
|
||||||
calc (a + 1) + (n + 1) = ((a + 1) + n) + 1 : add::succr (a + 1) n
|
calc (a + 1) + (n + 1) = ((a + 1) + n) + 1 : add_succr (a + 1) n
|
||||||
... = ((a + n) + 1) + 1 : { iH }
|
... = ((a + n) + 1) + 1 : { iH }
|
||||||
... = (a + (n + 1)) + 1 : { have (a + n) + 1 = a + (n + 1) : symm (add::succr a n) })
|
... = (a + (n + 1)) + 1 : { have (a + n) + 1 = a + (n + 1) : symm (add_succr a n) })
|
||||||
|
|
||||||
theorem add::comm (a b : Nat) : a + b = b + a
|
theorem add_comm (a b : Nat) : a + b = b + a
|
||||||
:= induction b
|
:= induction b
|
||||||
(calc a + 0 = a : add::zeror a
|
(calc a + 0 = a : add_zeror a
|
||||||
... = 0 + a : symm (add::zerol a))
|
... = 0 + a : symm (add_zerol a))
|
||||||
(λ (n : Nat) (iH : a + n = n + a),
|
(λ (n : Nat) (iH : a + n = n + a),
|
||||||
calc a + (n + 1) = (a + n) + 1 : add::succr a n
|
calc a + (n + 1) = (a + n) + 1 : add_succr a n
|
||||||
... = (n + a) + 1 : { iH }
|
... = (n + a) + 1 : { iH }
|
||||||
... = (n + 1) + a : symm (add::succl n a))
|
... = (n + 1) + a : symm (add_succl n a))
|
||||||
|
|
||||||
theorem add::assoc (a b c : Nat) : a + (b + c) = (a + b) + c
|
theorem add_assoc (a b c : Nat) : a + (b + c) = (a + b) + c
|
||||||
:= induction a
|
:= induction a
|
||||||
(calc 0 + (b + c) = b + c : add::zerol (b + c)
|
(calc 0 + (b + c) = b + c : add_zerol (b + c)
|
||||||
... = (0 + b) + c : { symm (add::zerol b) })
|
... = (0 + b) + c : { symm (add_zerol b) })
|
||||||
(λ (n : Nat) (iH : n + (b + c) = (n + b) + c),
|
(λ (n : Nat) (iH : n + (b + c) = (n + b) + c),
|
||||||
calc (n + 1) + (b + c) = (n + (b + c)) + 1 : add::succl n (b + c)
|
calc (n + 1) + (b + c) = (n + (b + c)) + 1 : add_succl n (b + c)
|
||||||
... = ((n + b) + c) + 1 : { iH }
|
... = ((n + b) + c) + 1 : { iH }
|
||||||
... = ((n + b) + 1) + c : symm (add::succl (n + b) c)
|
... = ((n + b) + 1) + c : symm (add_succl (n + b) c)
|
||||||
... = ((n + 1) + b) + c : { have (n + b) + 1 = (n + 1) + b : symm (add::succl n b) })
|
... = ((n + 1) + b) + c : { have (n + b) + 1 = (n + 1) + b : symm (add_succl n b) })
|
||||||
|
|
||||||
theorem mul::zerol (a : Nat) : 0 * a = 0
|
theorem mul_zerol (a : Nat) : 0 * a = 0
|
||||||
:= induction a
|
:= induction a
|
||||||
(have 0 * 0 = 0 : trivial)
|
(have 0 * 0 = 0 : trivial)
|
||||||
(λ (n : Nat) (iH : 0 * n = 0),
|
(λ (n : Nat) (iH : 0 * n = 0),
|
||||||
calc 0 * (n + 1) = (0 * n) + 0 : mul::succr 0 n
|
calc 0 * (n + 1) = (0 * n) + 0 : mul_succr 0 n
|
||||||
... = 0 + 0 : { iH }
|
... = 0 + 0 : { iH }
|
||||||
... = 0 : trivial)
|
... = 0 : trivial)
|
||||||
|
|
||||||
theorem mul::succl (a b : Nat) : (a + 1) * b = a * b + b
|
theorem mul_succl (a b : Nat) : (a + 1) * b = a * b + b
|
||||||
:= induction b
|
:= induction b
|
||||||
(calc (a + 1) * 0 = 0 : mul::zeror (a + 1)
|
(calc (a + 1) * 0 = 0 : mul_zeror (a + 1)
|
||||||
... = a * 0 : symm (mul::zeror a)
|
... = a * 0 : symm (mul_zeror a)
|
||||||
... = a * 0 + 0 : symm (add::zeror (a * 0)))
|
... = a * 0 + 0 : symm (add_zeror (a * 0)))
|
||||||
(λ (n : Nat) (iH : (a + 1) * n = a * n + n),
|
(λ (n : Nat) (iH : (a + 1) * n = a * n + n),
|
||||||
calc (a + 1) * (n + 1) = (a + 1) * n + (a + 1) : mul::succr (a + 1) n
|
calc (a + 1) * (n + 1) = (a + 1) * n + (a + 1) : mul_succr (a + 1) n
|
||||||
... = a * n + n + (a + 1) : { iH }
|
... = a * n + n + (a + 1) : { iH }
|
||||||
... = a * n + n + a + 1 : add::assoc (a * n + n) a 1
|
... = a * n + n + a + 1 : add_assoc (a * n + n) a 1
|
||||||
... = a * n + (n + a) + 1 : { have a * n + n + a = a * n + (n + a) : symm (add::assoc (a * n) n a) }
|
... = a * n + (n + a) + 1 : { have a * n + n + a = a * n + (n + a) : symm (add_assoc (a * n) n a) }
|
||||||
... = a * n + (a + n) + 1 : { add::comm n a }
|
... = a * n + (a + n) + 1 : { add_comm n a }
|
||||||
... = a * n + a + n + 1 : { add::assoc (a * n) a n }
|
... = a * n + a + n + 1 : { add_assoc (a * n) a n }
|
||||||
... = a * (n + 1) + n + 1 : { symm (mul::succr a n) }
|
... = a * (n + 1) + n + 1 : { symm (mul_succr a n) }
|
||||||
... = a * (n + 1) + (n + 1) : symm (add::assoc (a * (n + 1)) n 1))
|
... = a * (n + 1) + (n + 1) : symm (add_assoc (a * (n + 1)) n 1))
|
||||||
|
|
||||||
theorem mul::onel (a : Nat) : 1 * a = a
|
theorem mul_onel (a : Nat) : 1 * a = a
|
||||||
:= induction a
|
:= induction a
|
||||||
(have 1 * 0 = 0 : trivial)
|
(have 1 * 0 = 0 : trivial)
|
||||||
(λ (n : Nat) (iH : 1 * n = n),
|
(λ (n : Nat) (iH : 1 * n = n),
|
||||||
calc 1 * (n + 1) = 1 * n + 1 : mul::succr 1 n
|
calc 1 * (n + 1) = 1 * n + 1 : mul_succr 1 n
|
||||||
... = n + 1 : { iH })
|
... = n + 1 : { iH })
|
||||||
|
|
||||||
theorem mul::oner (a : Nat) : a * 1 = a
|
theorem mul_oner (a : Nat) : a * 1 = a
|
||||||
:= induction a
|
:= induction a
|
||||||
(have 0 * 1 = 0 : trivial)
|
(have 0 * 1 = 0 : trivial)
|
||||||
(λ (n : Nat) (iH : n * 1 = n),
|
(λ (n : Nat) (iH : n * 1 = n),
|
||||||
calc (n + 1) * 1 = n * 1 + 1 : mul::succl n 1
|
calc (n + 1) * 1 = n * 1 + 1 : mul_succl n 1
|
||||||
... = n + 1 : { iH })
|
... = n + 1 : { iH })
|
||||||
|
|
||||||
theorem mul::comm (a b : Nat) : a * b = b * a
|
theorem mul_comm (a b : Nat) : a * b = b * a
|
||||||
:= induction b
|
:= induction b
|
||||||
(calc a * 0 = 0 : mul::zeror a
|
(calc a * 0 = 0 : mul_zeror a
|
||||||
... = 0 * a : symm (mul::zerol a))
|
... = 0 * a : symm (mul_zerol a))
|
||||||
(λ (n : Nat) (iH : a * n = n * a),
|
(λ (n : Nat) (iH : a * n = n * a),
|
||||||
calc a * (n + 1) = a * n + a : mul::succr a n
|
calc a * (n + 1) = a * n + a : mul_succr a n
|
||||||
... = n * a + a : { iH }
|
... = n * a + a : { iH }
|
||||||
... = (n + 1) * a : symm (mul::succl n a))
|
... = (n + 1) * a : symm (mul_succl n a))
|
||||||
|
|
||||||
theorem distributer (a b c : Nat) : a * (b + c) = a * b + a * c
|
theorem distributer (a b c : Nat) : a * (b + c) = a * b + a * c
|
||||||
:= induction a
|
:= induction a
|
||||||
(calc 0 * (b + c) = 0 : mul::zerol (b + c)
|
(calc 0 * (b + c) = 0 : mul_zerol (b + c)
|
||||||
... = 0 + 0 : trivial
|
... = 0 + 0 : trivial
|
||||||
... = 0 * b + 0 : { symm (mul::zerol b) }
|
... = 0 * b + 0 : { symm (mul_zerol b) }
|
||||||
... = 0 * b + 0 * c : { symm (mul::zerol c) })
|
... = 0 * b + 0 * c : { symm (mul_zerol c) })
|
||||||
(λ (n : Nat) (iH : n * (b + c) = n * b + n * c),
|
(λ (n : Nat) (iH : n * (b + c) = n * b + n * c),
|
||||||
calc (n + 1) * (b + c) = n * (b + c) + (b + c) : mul::succl n (b + c)
|
calc (n + 1) * (b + c) = n * (b + c) + (b + c) : mul_succl n (b + c)
|
||||||
... = n * b + n * c + (b + c) : { iH }
|
... = n * b + n * c + (b + c) : { iH }
|
||||||
... = n * b + n * c + b + c : add::assoc (n * b + n * c) b c
|
... = n * b + n * c + b + c : add_assoc (n * b + n * c) b c
|
||||||
... = n * b + (n * c + b) + c : { symm (add::assoc (n * b) (n * c) b) }
|
... = n * b + (n * c + b) + c : { symm (add_assoc (n * b) (n * c) b) }
|
||||||
... = n * b + (b + n * c) + c : { add::comm (n * c) b }
|
... = n * b + (b + n * c) + c : { add_comm (n * c) b }
|
||||||
... = n * b + b + n * c + c : { add::assoc (n * b) b (n * c) }
|
... = n * b + b + n * c + c : { add_assoc (n * b) b (n * c) }
|
||||||
... = (n + 1) * b + n * c + c : { symm (mul::succl n b) }
|
... = (n + 1) * b + n * c + c : { symm (mul_succl n b) }
|
||||||
... = (n + 1) * b + (n * c + c) : symm (add::assoc ((n + 1) * b) (n * c) c)
|
... = (n + 1) * b + (n * c + c) : symm (add_assoc ((n + 1) * b) (n * c) c)
|
||||||
... = (n + 1) * b + (n + 1) * c : { symm (mul::succl n c) })
|
... = (n + 1) * b + (n + 1) * c : { symm (mul_succl n c) })
|
||||||
|
|
||||||
theorem distributel (a b c : Nat) : (a + b) * c = a * c + b * c
|
theorem distributel (a b c : Nat) : (a + b) * c = a * c + b * c
|
||||||
:= calc (a + b) * c = c * (a + b) : mul::comm (a + b) c
|
:= calc (a + b) * c = c * (a + b) : mul_comm (a + b) c
|
||||||
... = c * a + c * b : distributer c a b
|
... = c * a + c * b : distributer c a b
|
||||||
... = a * c + c * b : { mul::comm c a }
|
... = a * c + c * b : { mul_comm c a }
|
||||||
... = a * c + b * c : { mul::comm c b }
|
... = a * c + b * c : { mul_comm c b }
|
||||||
|
|
||||||
theorem mul::assoc (a b c : Nat) : a * (b * c) = a * b * c
|
theorem mul_assoc (a b c : Nat) : a * (b * c) = a * b * c
|
||||||
:= induction a
|
:= induction a
|
||||||
(calc 0 * (b * c) = 0 : mul::zerol (b * c)
|
(calc 0 * (b * c) = 0 : mul_zerol (b * c)
|
||||||
... = 0 * c : symm (mul::zerol c)
|
... = 0 * c : symm (mul_zerol c)
|
||||||
... = (0 * b) * c : { symm (mul::zerol b) })
|
... = (0 * b) * c : { symm (mul_zerol b) })
|
||||||
(λ (n : Nat) (iH : n * (b * c) = n * b * c),
|
(λ (n : Nat) (iH : n * (b * c) = n * b * c),
|
||||||
calc (n + 1) * (b * c) = n * (b * c) + (b * c) : mul::succl n (b * c)
|
calc (n + 1) * (b * c) = n * (b * c) + (b * c) : mul_succl n (b * c)
|
||||||
... = n * b * c + (b * c) : { iH }
|
... = n * b * c + (b * c) : { iH }
|
||||||
... = (n * b + b) * c : symm (distributel (n * b) b c)
|
... = (n * b + b) * c : symm (distributel (n * b) b c)
|
||||||
... = (n + 1) * b * c : { symm (mul::succl n b) })
|
... = (n + 1) * b * c : { symm (mul_succl n b) })
|
||||||
|
|
||||||
theorem add::inj {a b c : Nat} : a + b = a + c → b = c
|
theorem add_inj {a b c : Nat} : a + b = a + c → b = c
|
||||||
:= induction a
|
:= induction a
|
||||||
(λ H : 0 + b = 0 + c,
|
(λ H : 0 + b = 0 + c,
|
||||||
calc b = 0 + b : symm (add::zerol b)
|
calc b = 0 + b : symm (add_zerol b)
|
||||||
... = 0 + c : H
|
... = 0 + c : H
|
||||||
... = c : add::zerol c)
|
... = c : add_zerol c)
|
||||||
(λ (n : Nat) (iH : n + b = n + c → b = c) (H : n + 1 + b = n + 1 + c),
|
(λ (n : Nat) (iH : n + b = n + c → b = c) (H : n + 1 + b = n + 1 + c),
|
||||||
let L1 : n + b + 1 = n + c + 1
|
let L1 : n + b + 1 = n + c + 1
|
||||||
:= (calc n + b + 1 = n + (b + 1) : symm (add::assoc n b 1)
|
:= (calc n + b + 1 = n + (b + 1) : symm (add_assoc n b 1)
|
||||||
... = n + (1 + b) : { add::comm b 1 }
|
... = n + (1 + b) : { add_comm b 1 }
|
||||||
... = n + 1 + b : add::assoc n 1 b
|
... = n + 1 + b : add_assoc n 1 b
|
||||||
... = n + 1 + c : H
|
... = n + 1 + c : H
|
||||||
... = n + (1 + c) : symm (add::assoc n 1 c)
|
... = n + (1 + c) : symm (add_assoc n 1 c)
|
||||||
... = n + (c + 1) : { add::comm 1 c }
|
... = n + (c + 1) : { add_comm 1 c }
|
||||||
... = n + c + 1 : add::assoc n c 1),
|
... = n + c + 1 : add_assoc n c 1),
|
||||||
L2 : n + b = n + c := succ::inj L1
|
L2 : n + b = n + c := succ_inj L1
|
||||||
in iH L2)
|
in iH L2)
|
||||||
|
|
||||||
theorem add::eqz {a b : Nat} (H : a + b = 0) : a = 0
|
theorem add_eqz {a b : Nat} (H : a + b = 0) : a = 0
|
||||||
:= discriminate
|
:= discriminate
|
||||||
(λ H1 : a = 0, H1)
|
(λ H1 : a = 0, H1)
|
||||||
(λ (n : Nat) (H1 : a = n + 1),
|
(λ (n : Nat) (H1 : a = n + 1),
|
||||||
absurd::elim (a = 0)
|
absurd_elim (a = 0)
|
||||||
H (calc a + b = n + 1 + b : { H1 }
|
H (calc a + b = n + 1 + b : { H1 }
|
||||||
... = n + (1 + b) : symm (add::assoc n 1 b)
|
... = n + (1 + b) : symm (add_assoc n 1 b)
|
||||||
... = n + (b + 1) : { add::comm 1 b }
|
... = n + (b + 1) : { add_comm 1 b }
|
||||||
... = n + b + 1 : add::assoc n b 1
|
... = n + b + 1 : add_assoc n b 1
|
||||||
... ≠ 0 : succ::nz (n + b)))
|
... ≠ 0 : succ_nz (n + b)))
|
||||||
|
|
||||||
theorem le::intro {a b c : Nat} (H : a + c = b) : a ≤ b
|
theorem le_intro {a b c : Nat} (H : a + c = b) : a ≤ b
|
||||||
:= (symm (le::def a b)) ◂ (have (∃ x, a + x = b) : exists::intro c H)
|
:= (symm (le_def a b)) ◂ (have (∃ x, a + x = b) : exists_intro c H)
|
||||||
|
|
||||||
theorem le::elim {a b : Nat} (H : a ≤ b) : ∃ x, a + x = b
|
theorem le_elim {a b : Nat} (H : a ≤ b) : ∃ x, a + x = b
|
||||||
:= (le::def a b) ◂ H
|
:= (le_def a b) ◂ H
|
||||||
|
|
||||||
theorem le::refl (a : Nat) : a ≤ a := le::intro (add::zeror a)
|
theorem le_refl (a : Nat) : a ≤ a := le_intro (add_zeror a)
|
||||||
|
|
||||||
theorem le::zero (a : Nat) : 0 ≤ a := le::intro (add::zerol a)
|
theorem le_zero (a : Nat) : 0 ≤ a := le_intro (add_zerol a)
|
||||||
|
|
||||||
|
|
||||||
theorem le::trans {a b c : Nat} (H1 : a ≤ b) (H2 : b ≤ c) : a ≤ c
|
theorem le_trans {a b c : Nat} (H1 : a ≤ b) (H2 : b ≤ c) : a ≤ c
|
||||||
:= obtain (w1 : Nat) (Hw1 : a + w1 = b), from (le::elim H1),
|
:= obtain (w1 : Nat) (Hw1 : a + w1 = b), from (le_elim H1),
|
||||||
obtain (w2 : Nat) (Hw2 : b + w2 = c), from (le::elim H2),
|
obtain (w2 : Nat) (Hw2 : b + w2 = c), from (le_elim H2),
|
||||||
le::intro (calc a + (w1 + w2) = a + w1 + w2 : add::assoc a w1 w2
|
le_intro (calc a + (w1 + w2) = a + w1 + w2 : add_assoc a w1 w2
|
||||||
... = b + w2 : { Hw1 }
|
... = b + w2 : { Hw1 }
|
||||||
... = c : Hw2)
|
... = c : Hw2)
|
||||||
|
|
||||||
theorem le::add {a b : Nat} (H : a ≤ b) (c : Nat) : a + c ≤ b + c
|
theorem le_add {a b : Nat} (H : a ≤ b) (c : Nat) : a + c ≤ b + c
|
||||||
:= obtain (w : Nat) (Hw : a + w = b), from (le::elim H),
|
:= obtain (w : Nat) (Hw : a + w = b), from (le_elim H),
|
||||||
le::intro (calc a + c + w = a + (c + w) : symm (add::assoc a c w)
|
le_intro (calc a + c + w = a + (c + w) : symm (add_assoc a c w)
|
||||||
... = a + (w + c) : { add::comm c w }
|
... = a + (w + c) : { add_comm c w }
|
||||||
... = a + w + c : add::assoc a w c
|
... = a + w + c : add_assoc a w c
|
||||||
... = b + c : { Hw })
|
... = b + c : { Hw })
|
||||||
|
|
||||||
theorem le::antisym {a b : Nat} (H1 : a ≤ b) (H2 : b ≤ a) : a = b
|
theorem le_antisym {a b : Nat} (H1 : a ≤ b) (H2 : b ≤ a) : a = b
|
||||||
:= obtain (w1 : Nat) (Hw1 : a + w1 = b), from (le::elim H1),
|
:= obtain (w1 : Nat) (Hw1 : a + w1 = b), from (le_elim H1),
|
||||||
obtain (w2 : Nat) (Hw2 : b + w2 = a), from (le::elim H2),
|
obtain (w2 : Nat) (Hw2 : b + w2 = a), from (le_elim H2),
|
||||||
let L1 : w1 + w2 = 0
|
let L1 : w1 + w2 = 0
|
||||||
:= add::inj (calc a + (w1 + w2) = a + w1 + w2 : { add::assoc a w1 w2 }
|
:= add_inj (calc a + (w1 + w2) = a + w1 + w2 : { add_assoc a w1 w2 }
|
||||||
... = b + w2 : { Hw1 }
|
... = b + w2 : { Hw1 }
|
||||||
... = a : Hw2
|
... = a : Hw2
|
||||||
... = a + 0 : symm (add::zeror a)),
|
... = a + 0 : symm (add_zeror a)),
|
||||||
L2 : w1 = 0 := add::eqz L1
|
L2 : w1 = 0 := add_eqz L1
|
||||||
in calc a = a + 0 : symm (add::zeror a)
|
in calc a = a + 0 : symm (add_zeror a)
|
||||||
... = a + w1 : { symm L2 }
|
... = a + w1 : { symm L2 }
|
||||||
... = b : Hw1
|
... = b : Hw1
|
||||||
|
|
||||||
set::opaque add true
|
set_opaque add true
|
||||||
set::opaque mul true
|
set_opaque mul true
|
||||||
set::opaque le true
|
set_opaque le true
|
||||||
set::opaque id true
|
set_opaque id true
|
||||||
set::opaque ge true
|
set_opaque ge true
|
||||||
set::opaque lt true
|
set_opaque lt true
|
||||||
set::opaque gt true
|
set_opaque gt true
|
||||||
set::opaque id true
|
set_opaque id true
|
||||||
end
|
end
|
|
@ -8,7 +8,7 @@ universe U >= M + 1
|
||||||
definition TypeM := (Type M)
|
definition TypeM := (Type M)
|
||||||
|
|
||||||
-- Type equality axiom, if two values are equal, then their types are equal
|
-- Type equality axiom, if two values are equal, then their types are equal
|
||||||
theorem type::eq {A B : TypeM} {a : A} {b : B} (H : a == b) : A == B
|
theorem type_eq {A B : TypeM} {a : A} {b : B} (H : a == b) : A == B
|
||||||
:= hsubst (λ (T : TypeU) (x : T), A == T) (refl A) H
|
:= hsubst (λ (T : TypeU) (x : T), A == T) (refl A) H
|
||||||
|
|
||||||
-- Heterogenous symmetry
|
-- Heterogenous symmetry
|
||||||
|
@ -24,10 +24,10 @@ theorem htrans {A B C : TypeU} {a : A} {b : B} {c : C} (H1 : a == b) (H2 : b ==
|
||||||
variable cast {A B : TypeU} : A == B → A → B
|
variable cast {A B : TypeU} : A == B → A → B
|
||||||
|
|
||||||
-- The CastEq axiom states that for any cast of x is equal to x.
|
-- The CastEq axiom states that for any cast of x is equal to x.
|
||||||
axiom cast::eq {A B : TypeU} (H : A == B) (x : A) : x == cast H x
|
axiom cast_eq {A B : TypeU} (H : A == B) (x : A) : x == cast H x
|
||||||
|
|
||||||
-- The CastApp axiom "propagates" the cast over application
|
-- The CastApp axiom "propagates" the cast over application
|
||||||
axiom cast::app {A A' : TypeU} {B : A → TypeU} {B' : A' → TypeU}
|
axiom cast_app {A A' : TypeU} {B : A → TypeU} {B' : A' → TypeU}
|
||||||
(H1 : (∀ x : A, B x) == (∀ x : A', B' x)) (H2 : A == A')
|
(H1 : (∀ x : A, B x) == (∀ x : A', B' x)) (H2 : A == A')
|
||||||
(f : ∀ x : A, B x) (x : A) :
|
(f : ∀ x : A, B x) (x : A) :
|
||||||
cast H1 f (cast H2 x) == f x
|
cast H1 f (cast H2 x) == f x
|
||||||
|
@ -39,19 +39,19 @@ theorem hcongr
|
||||||
(H1 : f == g)
|
(H1 : f == g)
|
||||||
(H2 : a == b)
|
(H2 : a == b)
|
||||||
: f a == g b
|
: f a == g b
|
||||||
:= let L1 : A == A' := type::eq H2,
|
:= let L1 : A == A' := type_eq H2,
|
||||||
L2 : A' == A := symm L1,
|
L2 : A' == A := symm L1,
|
||||||
b' : A := cast L2 b,
|
b' : A := cast L2 b,
|
||||||
L3 : b == b' := cast::eq L2 b,
|
L3 : b == b' := cast_eq L2 b,
|
||||||
L4 : a == b' := htrans H2 L3,
|
L4 : a == b' := htrans H2 L3,
|
||||||
L5 : f a == f b' := congr2 f L4,
|
L5 : f a == f b' := congr2 f L4,
|
||||||
S1 : (∀ x : A', B' x) == (∀ x : A, B x) := symm (type::eq H1),
|
S1 : (∀ x : A', B' x) == (∀ x : A, B x) := symm (type_eq H1),
|
||||||
g' : (∀ x : A, B x) := cast S1 g,
|
g' : (∀ x : A, B x) := cast S1 g,
|
||||||
L6 : g == g' := cast::eq S1 g,
|
L6 : g == g' := cast_eq S1 g,
|
||||||
L7 : f == g' := htrans H1 L6,
|
L7 : f == g' := htrans H1 L6,
|
||||||
L8 : f b' == g' b' := congr1 b' L7,
|
L8 : f b' == g' b' := congr1 b' L7,
|
||||||
L9 : f a == g' b' := htrans L5 L8,
|
L9 : f a == g' b' := htrans L5 L8,
|
||||||
L10 : g' b' == g b := cast::app S1 L2 g b
|
L10 : g' b' == g b := cast_app S1 L2 g b
|
||||||
in htrans L9 L10
|
in htrans L9 L10
|
||||||
|
|
||||||
exit -- Stop here, the following axiom is not sound
|
exit -- Stop here, the following axiom is not sound
|
||||||
|
@ -72,9 +72,8 @@ theorem unsat : false :=
|
||||||
let L1 : (∀ x : true, true) := (λ x : true, trivial),
|
let L1 : (∀ x : true, true) := (λ x : true, trivial),
|
||||||
L2 : (∀ x : false, true) := (λ x : false, trivial),
|
L2 : (∀ x : false, true) := (λ x : false, trivial),
|
||||||
-- When we keep Pi/forall as different things, the following two steps can't be used
|
-- When we keep Pi/forall as different things, the following two steps can't be used
|
||||||
L3 : (∀ x : true, true) = true := eqt::intro L1,
|
L3 : (∀ x : true, true) = true := eqt_intro L1,
|
||||||
L4 : (∀ x : false, true) = true := eqt::intro L2,
|
L4 : (∀ x : false, true) = true := eqt_intro L2,
|
||||||
L5 : (∀ x : true, true) = (∀ x : false, true) := trans L3 (symm L4),
|
L5 : (∀ x : true, true) = (∀ x : false, true) := trans L3 (symm L4),
|
||||||
L6 : true = false := dominj L5
|
L6 : true = false := dominj L5
|
||||||
in L6
|
in L6
|
||||||
|
|
||||||
|
|
|
@ -83,23 +83,23 @@ infixl 100 ◂ : eqmp
|
||||||
theorem boolcomplete (a : Bool) : a == true ∨ a == false
|
theorem boolcomplete (a : Bool) : a == true ∨ a == false
|
||||||
:= case (λ x, x == true ∨ x == false) trivial trivial a
|
:= case (λ x, x == true ∨ x == false) trivial trivial a
|
||||||
|
|
||||||
theorem false::elim (a : Bool) (H : false) : a
|
theorem false_elim (a : Bool) (H : false) : a
|
||||||
:= case (λ x, x) trivial H a
|
:= case (λ x, x) trivial H a
|
||||||
|
|
||||||
theorem imp::trans {a b c : Bool} (H1 : a → b) (H2 : b → c) : a → c
|
theorem imp_trans {a b c : Bool} (H1 : a → b) (H2 : b → c) : a → c
|
||||||
:= λ Ha, H2 (H1 Ha)
|
:= λ Ha, H2 (H1 Ha)
|
||||||
|
|
||||||
theorem imp::eq::trans {a b c : Bool} (H1 : a → b) (H2 : b == c) : a → c
|
theorem imp_eq_trans {a b c : Bool} (H1 : a → b) (H2 : b == c) : a → c
|
||||||
:= λ Ha, H2 ◂ (H1 Ha)
|
:= λ Ha, H2 ◂ (H1 Ha)
|
||||||
|
|
||||||
theorem eq::imp::trans {a b c : Bool} (H1 : a == b) (H2 : b → c) : a → c
|
theorem eq_imp_trans {a b c : Bool} (H1 : a == b) (H2 : b → c) : a → c
|
||||||
:= λ Ha, H2 (H1 ◂ Ha)
|
:= λ Ha, H2 (H1 ◂ Ha)
|
||||||
|
|
||||||
theorem not::not::eq (a : Bool) : (¬ ¬ a) == a
|
theorem not_not_eq (a : Bool) : (¬ ¬ a) == a
|
||||||
:= case (λ x, (¬ ¬ x) == x) trivial trivial a
|
:= case (λ x, (¬ ¬ x) == x) trivial trivial a
|
||||||
|
|
||||||
theorem not::not::elim {a : Bool} (H : ¬ ¬ a) : a
|
theorem not_not_elim {a : Bool} (H : ¬ ¬ a) : a
|
||||||
:= (not::not::eq a) ◂ H
|
:= (not_not_eq a) ◂ H
|
||||||
|
|
||||||
theorem mt {a b : Bool} (H1 : a → b) (H2 : ¬ b) : ¬ a
|
theorem mt {a b : Bool} (H1 : a → b) (H2 : ¬ b) : ¬ a
|
||||||
:= λ Ha, absurd (H1 Ha) H2
|
:= λ Ha, absurd (H1 Ha) H2
|
||||||
|
@ -107,16 +107,16 @@ theorem mt {a b : Bool} (H1 : a → b) (H2 : ¬ b) : ¬ a
|
||||||
theorem contrapos {a b : Bool} (H : a → b) : ¬ b → ¬ a
|
theorem contrapos {a b : Bool} (H : a → b) : ¬ b → ¬ a
|
||||||
:= λ Hnb : ¬ b, mt H Hnb
|
:= λ Hnb : ¬ b, mt H Hnb
|
||||||
|
|
||||||
theorem absurd::elim {a : Bool} (b : Bool) (H1 : a) (H2 : ¬ a) : b
|
theorem absurd_elim {a : Bool} (b : Bool) (H1 : a) (H2 : ¬ a) : b
|
||||||
:= false::elim b (absurd H1 H2)
|
:= false_elim b (absurd H1 H2)
|
||||||
|
|
||||||
theorem not::imp::eliml {a b : Bool} (Hnab : ¬ (a → b)) : a
|
theorem not_imp_eliml {a b : Bool} (Hnab : ¬ (a → b)) : a
|
||||||
:= not::not::elim
|
:= not_not_elim
|
||||||
(have ¬ ¬ a :
|
(have ¬ ¬ a :
|
||||||
λ Hna : ¬ a, absurd (have a → b : λ Ha : a, absurd::elim b Ha Hna)
|
λ Hna : ¬ a, absurd (have a → b : λ Ha : a, absurd_elim b Ha Hna)
|
||||||
Hnab)
|
Hnab)
|
||||||
|
|
||||||
theorem not::imp::elimr {a b : Bool} (H : ¬ (a → b)) : ¬ b
|
theorem not_imp_elimr {a b : Bool} (H : ¬ (a → b)) : ¬ b
|
||||||
:= λ Hb : b, absurd (have a → b : λ Ha : a, Hb)
|
:= λ Hb : b, absurd (have a → b : λ Ha : a, Hb)
|
||||||
(have ¬ (a → b) : H)
|
(have ¬ (a → b) : H)
|
||||||
|
|
||||||
|
@ -124,30 +124,30 @@ theorem resolve1 {a b : Bool} (H1 : a ∨ b) (H2 : ¬ a) : b
|
||||||
:= H1 H2
|
:= H1 H2
|
||||||
|
|
||||||
-- Recall that and is defined as ¬ (a → ¬ b)
|
-- Recall that and is defined as ¬ (a → ¬ b)
|
||||||
theorem and::intro {a b : Bool} (H1 : a) (H2 : b) : a ∧ b
|
theorem and_intro {a b : Bool} (H1 : a) (H2 : b) : a ∧ b
|
||||||
:= λ H : a → ¬ b, absurd H2 (H H1)
|
:= λ H : a → ¬ b, absurd H2 (H H1)
|
||||||
|
|
||||||
theorem and::eliml {a b : Bool} (H : a ∧ b) : a
|
theorem and_eliml {a b : Bool} (H : a ∧ b) : a
|
||||||
:= not::imp::eliml H
|
:= not_imp_eliml H
|
||||||
|
|
||||||
theorem and::elimr {a b : Bool} (H : a ∧ b) : b
|
theorem and_elimr {a b : Bool} (H : a ∧ b) : b
|
||||||
:= not::not::elim (not::imp::elimr H)
|
:= not_not_elim (not_imp_elimr H)
|
||||||
|
|
||||||
-- Recall that or is defined as ¬ a → b
|
-- Recall that or is defined as ¬ a → b
|
||||||
theorem or::introl {a : Bool} (H : a) (b : Bool) : a ∨ b
|
theorem or_introl {a : Bool} (H : a) (b : Bool) : a ∨ b
|
||||||
:= λ H1 : ¬ a, absurd::elim b H H1
|
:= λ H1 : ¬ a, absurd_elim b H H1
|
||||||
|
|
||||||
theorem or::intror {b : Bool} (a : Bool) (H : b) : a ∨ b
|
theorem or_intror {b : Bool} (a : Bool) (H : b) : a ∨ b
|
||||||
:= λ H1 : ¬ a, H
|
:= λ H1 : ¬ a, H
|
||||||
|
|
||||||
theorem or::elim {a b c : Bool} (H1 : a ∨ b) (H2 : a → c) (H3 : b → c) : c
|
theorem or_elim {a b c : Bool} (H1 : a ∨ b) (H2 : a → c) (H3 : b → c) : c
|
||||||
:= not::not::elim
|
:= not_not_elim
|
||||||
(λ H : ¬ c,
|
(λ H : ¬ c,
|
||||||
absurd (have c : H3 (have b : resolve1 H1 (have ¬ a : (mt (λ Ha : a, H2 Ha) H))))
|
absurd (have c : H3 (have b : resolve1 H1 (have ¬ a : (mt (λ Ha : a, H2 Ha) H))))
|
||||||
H)
|
H)
|
||||||
|
|
||||||
theorem refute {a : Bool} (H : ¬ a → false) : a
|
theorem refute {a : Bool} (H : ¬ a → false) : a
|
||||||
:= or::elim (em a) (λ H1 : a, H1) (λ H1 : ¬ a, false::elim a (H H1))
|
:= or_elim (em a) (λ H1 : a, H1) (λ H1 : ¬ a, false_elim a (H H1))
|
||||||
|
|
||||||
theorem symm {A : TypeU} {a b : A} (H : a == b) : b == a
|
theorem symm {A : TypeU} {a b : A} (H : a == b) : b == a
|
||||||
:= subst (refl a) H
|
:= subst (refl a) H
|
||||||
|
@ -157,16 +157,16 @@ theorem trans {A : TypeU} {a b c : A} (H1 : a == b) (H2 : b == c) : a == c
|
||||||
|
|
||||||
infixl 100 ⋈ : trans
|
infixl 100 ⋈ : trans
|
||||||
|
|
||||||
theorem ne::symm {A : TypeU} {a b : A} (H : a ≠ b) : b ≠ a
|
theorem ne_symm {A : TypeU} {a b : A} (H : a ≠ b) : b ≠ a
|
||||||
:= λ H1 : b = a, H (symm H1)
|
:= λ H1 : b = a, H (symm H1)
|
||||||
|
|
||||||
theorem eq::ne::trans {A : TypeU} {a b c : A} (H1 : a = b) (H2 : b ≠ c) : a ≠ c
|
theorem eq_ne_trans {A : TypeU} {a b c : A} (H1 : a = b) (H2 : b ≠ c) : a ≠ c
|
||||||
:= subst H2 (symm H1)
|
:= subst H2 (symm H1)
|
||||||
|
|
||||||
theorem ne::eq::trans {A : TypeU} {a b c : A} (H1 : a ≠ b) (H2 : b = c) : a ≠ c
|
theorem ne_eq_trans {A : TypeU} {a b c : A} (H1 : a ≠ b) (H2 : b = c) : a ≠ c
|
||||||
:= subst H1 H2
|
:= subst H1 H2
|
||||||
|
|
||||||
theorem eqt::elim {a : Bool} (H : a == true) : a
|
theorem eqt_elim {a : Bool} (H : a == true) : a
|
||||||
:= (symm H) ◂ trivial
|
:= (symm H) ◂ trivial
|
||||||
|
|
||||||
theorem congr1 {A : TypeU} {B : A → TypeU} {f g : ∀ x : A, B x} (a : A) (H : f == g) : f a == g a
|
theorem congr1 {A : TypeU} {B : A → TypeU} {f g : ∀ x : A, B x} (a : A) (H : f == g) : f a == g a
|
||||||
|
@ -179,176 +179,176 @@ theorem congr {A : TypeU} {B : A → TypeU} {f g : ∀ x : A, B x} {a b : A} (H1
|
||||||
:= subst (congr2 f H2) (congr1 b H1)
|
:= subst (congr2 f H2) (congr1 b H1)
|
||||||
|
|
||||||
-- Recall that exists is defined as ¬ ∀ x : A, ¬ P x
|
-- Recall that exists is defined as ¬ ∀ x : A, ¬ P x
|
||||||
theorem exists::elim {A : TypeU} {P : A → Bool} {B : Bool} (H1 : Exists A P) (H2 : ∀ (a : A) (H : P a), B) : B
|
theorem exists_elim {A : TypeU} {P : A → Bool} {B : Bool} (H1 : Exists A P) (H2 : ∀ (a : A) (H : P a), B) : B
|
||||||
:= refute (λ R : ¬ B,
|
:= refute (λ R : ¬ B,
|
||||||
absurd (λ a : A, mt (λ H : P a, H2 a H) R)
|
absurd (λ a : A, mt (λ H : P a, H2 a H) R)
|
||||||
H1)
|
H1)
|
||||||
|
|
||||||
theorem exists::intro {A : TypeU} {P : A → Bool} (a : A) (H : P a) : Exists A P
|
theorem exists_intro {A : TypeU} {P : A → Bool} (a : A) (H : P a) : Exists A P
|
||||||
:= λ H1 : (∀ x : A, ¬ P x),
|
:= λ H1 : (∀ x : A, ¬ P x),
|
||||||
absurd H (H1 a)
|
absurd H (H1 a)
|
||||||
|
|
||||||
theorem boolext {a b : Bool} (Hab : a → b) (Hba : b → a) : a == b
|
theorem boolext {a b : Bool} (Hab : a → b) (Hba : b → a) : a == b
|
||||||
:= or::elim (boolcomplete a)
|
:= or_elim (boolcomplete a)
|
||||||
(λ Hat : a == true, or::elim (boolcomplete b)
|
(λ Hat : a == true, or_elim (boolcomplete b)
|
||||||
(λ Hbt : b == true, trans Hat (symm Hbt))
|
(λ Hbt : b == true, trans Hat (symm Hbt))
|
||||||
(λ Hbf : b == false, false::elim (a == b) (subst (Hab (eqt::elim Hat)) Hbf)))
|
(λ Hbf : b == false, false_elim (a == b) (subst (Hab (eqt_elim Hat)) Hbf)))
|
||||||
(λ Haf : a == false, or::elim (boolcomplete b)
|
(λ Haf : a == false, or_elim (boolcomplete b)
|
||||||
(λ Hbt : b == true, false::elim (a == b) (subst (Hba (eqt::elim Hbt)) Haf))
|
(λ Hbt : b == true, false_elim (a == b) (subst (Hba (eqt_elim Hbt)) Haf))
|
||||||
(λ Hbf : b == false, trans Haf (symm Hbf)))
|
(λ Hbf : b == false, trans Haf (symm Hbf)))
|
||||||
|
|
||||||
definition iff::intro {a b : Bool} (Hab : a → b) (Hba : b → a) := boolext Hab Hba
|
definition iff_intro {a b : Bool} (Hab : a → b) (Hba : b → a) := boolext Hab Hba
|
||||||
|
|
||||||
theorem eqt::intro {a : Bool} (H : a) : a == true
|
theorem eqt_intro {a : Bool} (H : a) : a == true
|
||||||
:= boolext (λ H1 : a, trivial)
|
:= boolext (λ H1 : a, trivial)
|
||||||
(λ H2 : true, H)
|
(λ H2 : true, H)
|
||||||
|
|
||||||
theorem or::comm (a b : Bool) : (a ∨ b) == (b ∨ a)
|
theorem or_comm (a b : Bool) : (a ∨ b) == (b ∨ a)
|
||||||
:= boolext (λ H, or::elim H (λ H1, or::intror b H1) (λ H2, or::introl H2 a))
|
:= boolext (λ H, or_elim H (λ H1, or_intror b H1) (λ H2, or_introl H2 a))
|
||||||
(λ H, or::elim H (λ H1, or::intror a H1) (λ H2, or::introl H2 b))
|
(λ H, or_elim H (λ H1, or_intror a H1) (λ H2, or_introl H2 b))
|
||||||
|
|
||||||
theorem or::assoc (a b c : Bool) : ((a ∨ b) ∨ c) == (a ∨ (b ∨ c))
|
theorem or_assoc (a b c : Bool) : ((a ∨ b) ∨ c) == (a ∨ (b ∨ c))
|
||||||
:= boolext (λ H : (a ∨ b) ∨ c,
|
:= boolext (λ H : (a ∨ b) ∨ c,
|
||||||
or::elim H (λ H1 : a ∨ b, or::elim H1 (λ Ha : a, or::introl Ha (b ∨ c)) (λ Hb : b, or::intror a (or::introl Hb c)))
|
or_elim H (λ H1 : a ∨ b, or_elim H1 (λ Ha : a, or_introl Ha (b ∨ c)) (λ Hb : b, or_intror a (or_introl Hb c)))
|
||||||
(λ Hc : c, or::intror a (or::intror b Hc)))
|
(λ Hc : c, or_intror a (or_intror b Hc)))
|
||||||
(λ H : a ∨ (b ∨ c),
|
(λ H : a ∨ (b ∨ c),
|
||||||
or::elim H (λ Ha : a, (or::introl (or::introl Ha b) c))
|
or_elim H (λ Ha : a, (or_introl (or_introl Ha b) c))
|
||||||
(λ H1 : b ∨ c, or::elim H1 (λ Hb : b, or::introl (or::intror a Hb) c)
|
(λ H1 : b ∨ c, or_elim H1 (λ Hb : b, or_introl (or_intror a Hb) c)
|
||||||
(λ Hc : c, or::intror (a ∨ b) Hc)))
|
(λ Hc : c, or_intror (a ∨ b) Hc)))
|
||||||
|
|
||||||
theorem or::id (a : Bool) : (a ∨ a) == a
|
theorem or_id (a : Bool) : (a ∨ a) == a
|
||||||
:= boolext (λ H, or::elim H (λ H1, H1) (λ H2, H2))
|
:= boolext (λ H, or_elim H (λ H1, H1) (λ H2, H2))
|
||||||
(λ H, or::introl H a)
|
(λ H, or_introl H a)
|
||||||
|
|
||||||
theorem or::falsel (a : Bool) : (a ∨ false) == a
|
theorem or_falsel (a : Bool) : (a ∨ false) == a
|
||||||
:= boolext (λ H, or::elim H (λ H1, H1) (λ H2, false::elim a H2))
|
:= boolext (λ H, or_elim H (λ H1, H1) (λ H2, false_elim a H2))
|
||||||
(λ H, or::introl H false)
|
(λ H, or_introl H false)
|
||||||
|
|
||||||
theorem or::falser (a : Bool) : (false ∨ a) == a
|
theorem or_falser (a : Bool) : (false ∨ a) == a
|
||||||
:= (or::comm false a) ⋈ (or::falsel a)
|
:= (or_comm false a) ⋈ (or_falsel a)
|
||||||
|
|
||||||
theorem or::truel (a : Bool) : (true ∨ a) == true
|
theorem or_truel (a : Bool) : (true ∨ a) == true
|
||||||
:= eqt::intro (case (λ x : Bool, true ∨ x) trivial trivial a)
|
:= eqt_intro (case (λ x : Bool, true ∨ x) trivial trivial a)
|
||||||
|
|
||||||
theorem or::truer (a : Bool) : (a ∨ true) == true
|
theorem or_truer (a : Bool) : (a ∨ true) == true
|
||||||
:= (or::comm a true) ⋈ (or::truel a)
|
:= (or_comm a true) ⋈ (or_truel a)
|
||||||
|
|
||||||
theorem or::tauto (a : Bool) : (a ∨ ¬ a) == true
|
theorem or_tauto (a : Bool) : (a ∨ ¬ a) == true
|
||||||
:= eqt::intro (em a)
|
:= eqt_intro (em a)
|
||||||
|
|
||||||
theorem and::comm (a b : Bool) : (a ∧ b) == (b ∧ a)
|
theorem and_comm (a b : Bool) : (a ∧ b) == (b ∧ a)
|
||||||
:= boolext (λ H, and::intro (and::elimr H) (and::eliml H))
|
:= boolext (λ H, and_intro (and_elimr H) (and_eliml H))
|
||||||
(λ H, and::intro (and::elimr H) (and::eliml H))
|
(λ H, and_intro (and_elimr H) (and_eliml H))
|
||||||
|
|
||||||
theorem and::id (a : Bool) : (a ∧ a) == a
|
theorem and_id (a : Bool) : (a ∧ a) == a
|
||||||
:= boolext (λ H, and::eliml H)
|
:= boolext (λ H, and_eliml H)
|
||||||
(λ H, and::intro H H)
|
(λ H, and_intro H H)
|
||||||
|
|
||||||
theorem and::assoc (a b c : Bool) : ((a ∧ b) ∧ c) == (a ∧ (b ∧ c))
|
theorem and_assoc (a b c : Bool) : ((a ∧ b) ∧ c) == (a ∧ (b ∧ c))
|
||||||
:= boolext (λ H, and::intro (and::eliml (and::eliml H)) (and::intro (and::elimr (and::eliml H)) (and::elimr H)))
|
:= boolext (λ H, and_intro (and_eliml (and_eliml H)) (and_intro (and_elimr (and_eliml H)) (and_elimr H)))
|
||||||
(λ H, and::intro (and::intro (and::eliml H) (and::eliml (and::elimr H))) (and::elimr (and::elimr H)))
|
(λ H, and_intro (and_intro (and_eliml H) (and_eliml (and_elimr H))) (and_elimr (and_elimr H)))
|
||||||
|
|
||||||
theorem and::truer (a : Bool) : (a ∧ true) == a
|
theorem and_truer (a : Bool) : (a ∧ true) == a
|
||||||
:= boolext (λ H : a ∧ true, and::eliml H)
|
:= boolext (λ H : a ∧ true, and_eliml H)
|
||||||
(λ H : a, and::intro H trivial)
|
(λ H : a, and_intro H trivial)
|
||||||
|
|
||||||
theorem and::truel (a : Bool) : (true ∧ a) == a
|
theorem and_truel (a : Bool) : (true ∧ a) == a
|
||||||
:= trans (and::comm true a) (and::truer a)
|
:= trans (and_comm true a) (and_truer a)
|
||||||
|
|
||||||
theorem and::falsel (a : Bool) : (a ∧ false) == false
|
theorem and_falsel (a : Bool) : (a ∧ false) == false
|
||||||
:= boolext (λ H, and::elimr H)
|
:= boolext (λ H, and_elimr H)
|
||||||
(λ H, false::elim (a ∧ false) H)
|
(λ H, false_elim (a ∧ false) H)
|
||||||
|
|
||||||
theorem and::falser (a : Bool) : (false ∧ a) == false
|
theorem and_falser (a : Bool) : (false ∧ a) == false
|
||||||
:= (and::comm false a) ⋈ (and::falsel a)
|
:= (and_comm false a) ⋈ (and_falsel a)
|
||||||
|
|
||||||
theorem and::absurd (a : Bool) : (a ∧ ¬ a) == false
|
theorem and_absurd (a : Bool) : (a ∧ ¬ a) == false
|
||||||
:= boolext (λ H, absurd (and::eliml H) (and::elimr H))
|
:= boolext (λ H, absurd (and_eliml H) (and_elimr H))
|
||||||
(λ H, false::elim (a ∧ ¬ a) H)
|
(λ H, false_elim (a ∧ ¬ a) H)
|
||||||
|
|
||||||
theorem not::true : (¬ true) == false
|
theorem not_true : (¬ true) == false
|
||||||
:= trivial
|
:= trivial
|
||||||
|
|
||||||
theorem not::false : (¬ false) == true
|
theorem not_false : (¬ false) == true
|
||||||
:= trivial
|
:= trivial
|
||||||
|
|
||||||
theorem not::and (a b : Bool) : (¬ (a ∧ b)) == (¬ a ∨ ¬ b)
|
theorem not_and (a b : Bool) : (¬ (a ∧ b)) == (¬ a ∨ ¬ b)
|
||||||
:= case (λ x, (¬ (x ∧ b)) == (¬ x ∨ ¬ b))
|
:= case (λ x, (¬ (x ∧ b)) == (¬ x ∨ ¬ b))
|
||||||
(case (λ y, (¬ (true ∧ y)) == (¬ true ∨ ¬ y)) trivial trivial b)
|
(case (λ y, (¬ (true ∧ y)) == (¬ true ∨ ¬ y)) trivial trivial b)
|
||||||
(case (λ y, (¬ (false ∧ y)) == (¬ false ∨ ¬ y)) trivial trivial b)
|
(case (λ y, (¬ (false ∧ y)) == (¬ false ∨ ¬ y)) trivial trivial b)
|
||||||
a
|
a
|
||||||
|
|
||||||
theorem not::and::elim {a b : Bool} (H : ¬ (a ∧ b)) : ¬ a ∨ ¬ b
|
theorem not_and_elim {a b : Bool} (H : ¬ (a ∧ b)) : ¬ a ∨ ¬ b
|
||||||
:= (not::and a b) ◂ H
|
:= (not_and a b) ◂ H
|
||||||
|
|
||||||
theorem not::or (a b : Bool) : (¬ (a ∨ b)) == (¬ a ∧ ¬ b)
|
theorem not_or (a b : Bool) : (¬ (a ∨ b)) == (¬ a ∧ ¬ b)
|
||||||
:= case (λ x, (¬ (x ∨ b)) == (¬ x ∧ ¬ b))
|
:= case (λ x, (¬ (x ∨ b)) == (¬ x ∧ ¬ b))
|
||||||
(case (λ y, (¬ (true ∨ y)) == (¬ true ∧ ¬ y)) trivial trivial b)
|
(case (λ y, (¬ (true ∨ y)) == (¬ true ∧ ¬ y)) trivial trivial b)
|
||||||
(case (λ y, (¬ (false ∨ y)) == (¬ false ∧ ¬ y)) trivial trivial b)
|
(case (λ y, (¬ (false ∨ y)) == (¬ false ∧ ¬ y)) trivial trivial b)
|
||||||
a
|
a
|
||||||
|
|
||||||
theorem not::or::elim {a b : Bool} (H : ¬ (a ∨ b)) : ¬ a ∧ ¬ b
|
theorem not_or_elim {a b : Bool} (H : ¬ (a ∨ b)) : ¬ a ∧ ¬ b
|
||||||
:= (not::or a b) ◂ H
|
:= (not_or a b) ◂ H
|
||||||
|
|
||||||
theorem not::iff (a b : Bool) : (¬ (a == b)) == ((¬ a) == b)
|
theorem not_iff (a b : Bool) : (¬ (a == b)) == ((¬ a) == b)
|
||||||
:= case (λ x, (¬ (x == b)) == ((¬ x) == b))
|
:= case (λ x, (¬ (x == b)) == ((¬ x) == b))
|
||||||
(case (λ y, (¬ (true == y)) == ((¬ true) == y)) trivial trivial b)
|
(case (λ y, (¬ (true == y)) == ((¬ true) == y)) trivial trivial b)
|
||||||
(case (λ y, (¬ (false == y)) == ((¬ false) == y)) trivial trivial b)
|
(case (λ y, (¬ (false == y)) == ((¬ false) == y)) trivial trivial b)
|
||||||
a
|
a
|
||||||
|
|
||||||
theorem not::iff::elim {a b : Bool} (H : ¬ (a == b)) : (¬ a) == b
|
theorem not_iff_elim {a b : Bool} (H : ¬ (a == b)) : (¬ a) == b
|
||||||
:= (not::iff a b) ◂ H
|
:= (not_iff a b) ◂ H
|
||||||
|
|
||||||
theorem not::implies (a b : Bool) : (¬ (a → b)) == (a ∧ ¬ b)
|
theorem not_implies (a b : Bool) : (¬ (a → b)) == (a ∧ ¬ b)
|
||||||
:= case (λ x, (¬ (x → b)) == (x ∧ ¬ b))
|
:= case (λ x, (¬ (x → b)) == (x ∧ ¬ b))
|
||||||
(case (λ y, (¬ (true → y)) == (true ∧ ¬ y)) trivial trivial b)
|
(case (λ y, (¬ (true → y)) == (true ∧ ¬ y)) trivial trivial b)
|
||||||
(case (λ y, (¬ (false → y)) == (false ∧ ¬ y)) trivial trivial b)
|
(case (λ y, (¬ (false → y)) == (false ∧ ¬ y)) trivial trivial b)
|
||||||
a
|
a
|
||||||
|
|
||||||
theorem not::implies::elim {a b : Bool} (H : ¬ (a → b)) : a ∧ ¬ b
|
theorem not_implies_elim {a b : Bool} (H : ¬ (a → b)) : a ∧ ¬ b
|
||||||
:= (not::implies a b) ◂ H
|
:= (not_implies a b) ◂ H
|
||||||
|
|
||||||
theorem not::congr {a b : Bool} (H : a == b) : (¬ a) == (¬ b)
|
theorem not_congr {a b : Bool} (H : a == b) : (¬ a) == (¬ b)
|
||||||
:= congr2 not H
|
:= congr2 not H
|
||||||
|
|
||||||
theorem eq::exists::intro {A : (Type U)} {P Q : A → Bool} (H : ∀ x : A, P x == Q x) : (∃ x : A, P x) == (∃ x : A, Q x)
|
theorem eq_exists_intro {A : (Type U)} {P Q : A → Bool} (H : ∀ x : A, P x == Q x) : (∃ x : A, P x) == (∃ x : A, Q x)
|
||||||
:= congr2 (Exists A) (funext H)
|
:= congr2 (Exists A) (funext H)
|
||||||
|
|
||||||
theorem not::forall (A : (Type U)) (P : A → Bool) : (¬ (∀ x : A, P x)) == (∃ x : A, ¬ P x)
|
theorem not_forall (A : (Type U)) (P : A → Bool) : (¬ (∀ x : A, P x)) == (∃ x : A, ¬ P x)
|
||||||
:= calc (¬ ∀ x : A, P x) = (¬ ∀ x : A, ¬ ¬ P x) : not::congr (allext (λ x : A, symm (not::not::eq (P x))))
|
:= calc (¬ ∀ x : A, P x) = (¬ ∀ x : A, ¬ ¬ P x) : not_congr (allext (λ x : A, symm (not_not_eq (P x))))
|
||||||
... = (∃ x : A, ¬ P x) : refl (∃ x : A, ¬ P x)
|
... = (∃ x : A, ¬ P x) : refl (∃ x : A, ¬ P x)
|
||||||
|
|
||||||
theorem not::forall::elim {A : (Type U)} {P : A → Bool} (H : ¬ (∀ x : A, P x)) : ∃ x : A, ¬ P x
|
theorem not_forall_elim {A : (Type U)} {P : A → Bool} (H : ¬ (∀ x : A, P x)) : ∃ x : A, ¬ P x
|
||||||
:= (not::forall A P) ◂ H
|
:= (not_forall A P) ◂ H
|
||||||
|
|
||||||
theorem not::exists (A : (Type U)) (P : A → Bool) : (¬ ∃ x : A, P x) == (∀ x : A, ¬ P x)
|
theorem not_exists (A : (Type U)) (P : A → Bool) : (¬ ∃ x : A, P x) == (∀ x : A, ¬ P x)
|
||||||
:= calc (¬ ∃ x : A, P x) = (¬ ¬ ∀ x : A, ¬ P x) : refl (¬ ∃ x : A, P x)
|
:= calc (¬ ∃ x : A, P x) = (¬ ¬ ∀ x : A, ¬ P x) : refl (¬ ∃ x : A, P x)
|
||||||
... = (∀ x : A, ¬ P x) : not::not::eq (∀ x : A, ¬ P x)
|
... = (∀ x : A, ¬ P x) : not_not_eq (∀ x : A, ¬ P x)
|
||||||
|
|
||||||
theorem not::exists::elim {A : (Type U)} {P : A → Bool} (H : ¬ ∃ x : A, P x) : ∀ x : A, ¬ P x
|
theorem not_exists_elim {A : (Type U)} {P : A → Bool} (H : ¬ ∃ x : A, P x) : ∀ x : A, ¬ P x
|
||||||
:= (not::exists A P) ◂ H
|
:= (not_exists A P) ◂ H
|
||||||
|
|
||||||
theorem exists::unfold1 {A : TypeU} {P : A → Bool} (a : A) (H : ∃ x : A, P x) : P a ∨ (∃ x : A, x ≠ a ∧ P x)
|
theorem exists_unfold1 {A : TypeU} {P : A → Bool} (a : A) (H : ∃ x : A, P x) : P a ∨ (∃ x : A, x ≠ a ∧ P x)
|
||||||
:= exists::elim H
|
:= exists_elim H
|
||||||
(λ (w : A) (H1 : P w),
|
(λ (w : A) (H1 : P w),
|
||||||
or::elim (em (w = a))
|
or_elim (em (w = a))
|
||||||
(λ Heq : w = a, or::introl (subst H1 Heq) (∃ x : A, x ≠ a ∧ P x))
|
(λ Heq : w = a, or_introl (subst H1 Heq) (∃ x : A, x ≠ a ∧ P x))
|
||||||
(λ Hne : w ≠ a, or::intror (P a) (exists::intro w (and::intro Hne H1))))
|
(λ Hne : w ≠ a, or_intror (P a) (exists_intro w (and_intro Hne H1))))
|
||||||
|
|
||||||
theorem exists::unfold2 {A : TypeU} {P : A → Bool} (a : A) (H : P a ∨ (∃ x : A, x ≠ a ∧ P x)) : ∃ x : A, P x
|
theorem exists_unfold2 {A : TypeU} {P : A → Bool} (a : A) (H : P a ∨ (∃ x : A, x ≠ a ∧ P x)) : ∃ x : A, P x
|
||||||
:= or::elim H
|
:= or_elim H
|
||||||
(λ H1 : P a, exists::intro a H1)
|
(λ H1 : P a, exists_intro a H1)
|
||||||
(λ H2 : (∃ x : A, x ≠ a ∧ P x),
|
(λ H2 : (∃ x : A, x ≠ a ∧ P x),
|
||||||
exists::elim H2
|
exists_elim H2
|
||||||
(λ (w : A) (Hw : w ≠ a ∧ P w),
|
(λ (w : A) (Hw : w ≠ a ∧ P w),
|
||||||
exists::intro w (and::elimr Hw)))
|
exists_intro w (and_elimr Hw)))
|
||||||
|
|
||||||
theorem exists::unfold {A : TypeU} (P : A → Bool) (a : A) : (∃ x : A, P x) = (P a ∨ (∃ x : A, x ≠ a ∧ P x))
|
theorem exists_unfold {A : TypeU} (P : A → Bool) (a : A) : (∃ x : A, P x) = (P a ∨ (∃ x : A, x ≠ a ∧ P x))
|
||||||
:= boolext (λ H : (∃ x : A, P x), exists::unfold1 a H)
|
:= boolext (λ H : (∃ x : A, P x), exists_unfold1 a H)
|
||||||
(λ H : (P a ∨ (∃ x : A, x ≠ a ∧ P x)), exists::unfold2 a H)
|
(λ H : (P a ∨ (∃ x : A, x ≠ a ∧ P x)), exists_unfold2 a H)
|
||||||
|
|
||||||
set::opaque exists true
|
set_opaque exists true
|
||||||
set::opaque not true
|
set_opaque not true
|
||||||
set::opaque or true
|
set_opaque or true
|
||||||
set::opaque and true
|
set_opaque and true
|
||||||
set::opaque implies true
|
set_opaque implies true
|
|
@ -92,7 +92,7 @@ macro("obtain", { macro_arg.Parameters, macro_arg.Comma, macro_arg.Id, macro_arg
|
||||||
if fromid ~= name("from") then
|
if fromid ~= name("from") then
|
||||||
error("invalid 'obtain' expression, 'from' keyword expected, got '" .. tostring(fromid) .. "'")
|
error("invalid 'obtain' expression, 'from' keyword expected, got '" .. tostring(fromid) .. "'")
|
||||||
end
|
end
|
||||||
local exElim = mk_constant({"exists", "elim"})
|
local exElim = mk_constant("exists_elim")
|
||||||
local H_name = bindings[n][1]
|
local H_name = bindings[n][1]
|
||||||
local H_type = bindings[n][2]
|
local H_type = bindings[n][2]
|
||||||
local a_name = bindings[n-1][1]
|
local a_name = bindings[n-1][1]
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -44,11 +44,11 @@ void calc_proof_parser::add_trans_step(expr const & op1, expr const & op2, trans
|
||||||
m_trans_ops.emplace_front(op1, op2, d);
|
m_trans_ops.emplace_front(op1, op2, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
static name g_eq_imp_trans({"eq", "imp", "trans"});
|
static name g_eq_imp_trans("eq_imp_trans");
|
||||||
static name g_imp_eq_trans({"imp", "eq", "trans"});
|
static name g_imp_eq_trans("imp_eq_trans");
|
||||||
static name g_imp_trans({"imp", "trans"});
|
static name g_imp_trans("imp_trans");
|
||||||
static name g_eq_ne_trans({"eq", "ne", "trans"});
|
static name g_eq_ne_trans("eq_ne_trans");
|
||||||
static name g_ne_eq_trans({"ne", "eq", "trans"});
|
static name g_ne_eq_trans("ne_eq_trans");
|
||||||
static name g_neq("neq");
|
static name g_neq("neq");
|
||||||
|
|
||||||
calc_proof_parser::calc_proof_parser() {
|
calc_proof_parser::calc_proof_parser() {
|
||||||
|
|
|
@ -37,8 +37,8 @@ static name g_infix_kwd("infix");
|
||||||
static name g_infixl_kwd("infixl");
|
static name g_infixl_kwd("infixl");
|
||||||
static name g_infixr_kwd("infixr");
|
static name g_infixr_kwd("infixr");
|
||||||
static name g_notation_kwd("notation");
|
static name g_notation_kwd("notation");
|
||||||
static name g_set_option_kwd("set", "option");
|
static name g_set_option_kwd("set_option");
|
||||||
static name g_set_opaque_kwd("set", "opaque");
|
static name g_set_opaque_kwd("set_opaque");
|
||||||
static name g_options_kwd("options");
|
static name g_options_kwd("options");
|
||||||
static name g_env_kwd("environment");
|
static name g_env_kwd("environment");
|
||||||
static name g_import_kwd("import");
|
static name g_import_kwd("import");
|
||||||
|
@ -46,7 +46,7 @@ static name g_help_kwd("help");
|
||||||
static name g_coercion_kwd("coercion");
|
static name g_coercion_kwd("coercion");
|
||||||
static name g_exit_kwd("exit");
|
static name g_exit_kwd("exit");
|
||||||
static name g_print_kwd("print");
|
static name g_print_kwd("print");
|
||||||
static name g_pop_kwd("pop", "scope");
|
static name g_pop_kwd("pop_scope");
|
||||||
static name g_scope_kwd("scope");
|
static name g_scope_kwd("scope");
|
||||||
static name g_builtin_kwd("builtin");
|
static name g_builtin_kwd("builtin");
|
||||||
static name g_namespace_kwd("namespace");
|
static name g_namespace_kwd("namespace");
|
||||||
|
|
|
@ -137,35 +137,35 @@ MK_CONSTANT(hsymm_fn, name("hsymm"));
|
||||||
MK_CONSTANT(eta_fn, name("eta"));
|
MK_CONSTANT(eta_fn, name("eta"));
|
||||||
MK_CONSTANT(imp_antisym_fn, name("iffintro"));
|
MK_CONSTANT(imp_antisym_fn, name("iffintro"));
|
||||||
MK_CONSTANT(trivial, name("trivial"));
|
MK_CONSTANT(trivial, name("trivial"));
|
||||||
MK_CONSTANT(false_elim_fn, name({"false", "elim"}));
|
MK_CONSTANT(false_elim_fn, name("false_elim"));
|
||||||
MK_CONSTANT(absurd_fn, name("absurd"));
|
MK_CONSTANT(absurd_fn, name("absurd"));
|
||||||
MK_CONSTANT(em_fn, name("em"));
|
MK_CONSTANT(em_fn, name("em"));
|
||||||
MK_CONSTANT(double_neg_fn, name("doubleneg"));
|
MK_CONSTANT(double_neg_fn, name("doubleneg"));
|
||||||
MK_CONSTANT(double_neg_elim_fn, name({"doubleneg", "elim"}));
|
MK_CONSTANT(double_neg_elim_fn, name("doubleneg_elim"));
|
||||||
MK_CONSTANT(mt_fn, name("mt"));
|
MK_CONSTANT(mt_fn, name("mt"));
|
||||||
MK_CONSTANT(contrapos_fn, name("contrapos"));
|
MK_CONSTANT(contrapos_fn, name("contrapos"));
|
||||||
MK_CONSTANT(absurd_elim_fn, name({"absurd", "elim"}));
|
MK_CONSTANT(absurd_elim_fn, name("absurd_elim"));
|
||||||
MK_CONSTANT(eq_mp_fn, name("eqmp"));
|
MK_CONSTANT(eq_mp_fn, name("eqmp"));
|
||||||
MK_CONSTANT(not_imp1_fn, name({"not", "imp", "eliml"}));
|
MK_CONSTANT(not_imp1_fn, name("not_imp_eliml"));
|
||||||
MK_CONSTANT(not_imp2_fn, name({"not", "imp", "elimr"}));
|
MK_CONSTANT(not_imp2_fn, name("not_imp_elimr"));
|
||||||
MK_CONSTANT(conj_fn, name({"and", "intro"}));
|
MK_CONSTANT(conj_fn, name("and_intro"));
|
||||||
MK_CONSTANT(conjunct1_fn, name({"and", "eliml"}));
|
MK_CONSTANT(conjunct1_fn, name("and_eliml"));
|
||||||
MK_CONSTANT(conjunct2_fn, name({"and", "elimr"}));
|
MK_CONSTANT(conjunct2_fn, name("and_elimr"));
|
||||||
MK_CONSTANT(disj1_fn, name({"or", "introl"}));
|
MK_CONSTANT(disj1_fn, name("or_introl"));
|
||||||
MK_CONSTANT(disj2_fn, name({"or", "intror"}));
|
MK_CONSTANT(disj2_fn, name("or_intror"));
|
||||||
MK_CONSTANT(disj_cases_fn, name({"or", "elim"}));
|
MK_CONSTANT(disj_cases_fn, name("or_elim"));
|
||||||
MK_CONSTANT(refute_fn, name("refute"));
|
MK_CONSTANT(refute_fn, name("refute"));
|
||||||
MK_CONSTANT(symm_fn, name("symm"));
|
MK_CONSTANT(symm_fn, name("symm"));
|
||||||
MK_CONSTANT(trans_fn, name("trans"));
|
MK_CONSTANT(trans_fn, name("trans"));
|
||||||
MK_CONSTANT(congr1_fn, name("congr1"));
|
MK_CONSTANT(congr1_fn, name("congr1"));
|
||||||
MK_CONSTANT(congr2_fn, name("congr2"));
|
MK_CONSTANT(congr2_fn, name("congr2"));
|
||||||
MK_CONSTANT(congr_fn, name("congr"));
|
MK_CONSTANT(congr_fn, name("congr"));
|
||||||
MK_CONSTANT(eqt_elim_fn, name({"eqt", "elim"}));
|
MK_CONSTANT(eqt_elim_fn, name("eqt_elim"));
|
||||||
MK_CONSTANT(eqt_intro_fn, name({"eqt", "intro"}));
|
MK_CONSTANT(eqt_intro_fn, name("eqt_intro"));
|
||||||
MK_CONSTANT(forall_elim_fn, name({"forall", "elim"}));
|
MK_CONSTANT(forall_elim_fn, name("forall_elim"));
|
||||||
MK_CONSTANT(forall_intro_fn, name({"forall", "intro"}));
|
MK_CONSTANT(forall_intro_fn, name("forall_intro"));
|
||||||
MK_CONSTANT(exists_elim_fn, name({"exists", "elim"}));
|
MK_CONSTANT(exists_elim_fn, name("exists_elim"));
|
||||||
MK_CONSTANT(exists_intro_fn, name({"exists", "intro"}));
|
MK_CONSTANT(exists_intro_fn, name("exists_intro"));
|
||||||
|
|
||||||
void import_kernel(environment const & env, io_state const & ios) {
|
void import_kernel(environment const & env, io_state const & ios) {
|
||||||
env->import("kernel", ios);
|
env->import("kernel", ios);
|
||||||
|
|
|
@ -34,7 +34,7 @@ class set_opaque_command : public neutral_object_cell {
|
||||||
public:
|
public:
|
||||||
set_opaque_command(name const & n, bool opaque):m_obj_name(n), m_opaque(opaque) {}
|
set_opaque_command(name const & n, bool opaque):m_obj_name(n), m_opaque(opaque) {}
|
||||||
virtual ~set_opaque_command() {}
|
virtual ~set_opaque_command() {}
|
||||||
virtual char const * keyword() const { return "set::opaque"; }
|
virtual char const * keyword() const { return "set_opaque"; }
|
||||||
virtual void write(serializer & s) const { s << "Opa" << m_obj_name << m_opaque; }
|
virtual void write(serializer & s) const { s << "Opa" << m_obj_name << m_opaque; }
|
||||||
name const & get_obj_name() const { return m_obj_name; }
|
name const & get_obj_name() const { return m_obj_name; }
|
||||||
bool get_flag() const { return m_opaque; }
|
bool get_flag() const { return m_opaque; }
|
||||||
|
|
|
@ -94,11 +94,11 @@ static void tst3() {
|
||||||
parse_error(env, ios, "check U");
|
parse_error(env, ios, "check U");
|
||||||
parse(env, ios, "variable h : Real -> Real -> Real. notation 10 [ _ ; _ ] : h. check [ 10.3 ; 20.1 ].");
|
parse(env, ios, "variable h : Real -> Real -> Real. notation 10 [ _ ; _ ] : h. check [ 10.3 ; 20.1 ].");
|
||||||
parse_error(env, ios, "variable h : Real -> Real -> Real. notation 10 [ _ ; _ ] : h. check [ 10.3 | 20.1 ].");
|
parse_error(env, ios, "variable h : Real -> Real -> Real. notation 10 [ _ ; _ ] : h. check [ 10.3 | 20.1 ].");
|
||||||
parse_error(env, ios, "set::option pp::indent true");
|
parse_error(env, ios, "set_option pp::indent true");
|
||||||
parse(env, ios, "set::option pp::indent 10");
|
parse(env, ios, "set_option pp::indent 10");
|
||||||
parse_error(env, ios, "set::option pp::colors foo");
|
parse_error(env, ios, "set_option pp::colors foo");
|
||||||
parse_error(env, ios, "set::option pp::colors \"foo\"");
|
parse_error(env, ios, "set_option pp::colors \"foo\"");
|
||||||
parse(env, ios, "set::option pp::colors true");
|
parse(env, ios, "set_option pp::colors true");
|
||||||
parse_error(env, ios, "notation 10 : Int::add");
|
parse_error(env, ios, "notation 10 : Int::add");
|
||||||
parse_error(env, ios, "notation 10 _ : Int::add");
|
parse_error(env, ios, "notation 10 _ : Int::add");
|
||||||
parse(env, ios, "notation 10 _ ++ _ : Int::add. eval 10 ++ 20.");
|
parse(env, ios, "notation 10 _ ++ _ : Int::add. eval 10 ++ 20.");
|
||||||
|
|
|
@ -2,5 +2,5 @@ import Int.
|
||||||
axiom PlusComm(a b : Int) : a + b == b + a.
|
axiom PlusComm(a b : Int) : a + b == b + a.
|
||||||
variable a : Int.
|
variable a : Int.
|
||||||
check (funext (fun x : Int, (PlusComm a x))).
|
check (funext (fun x : Int, (PlusComm a x))).
|
||||||
set::option pp::implicit true.
|
set_option pp::implicit true.
|
||||||
check (funext (fun x : Int, (PlusComm a x))).
|
check (funext (fun x : Int, (PlusComm a x))).
|
||||||
|
|
|
@ -3,14 +3,14 @@ scope
|
||||||
alias ℕℕ : Natural.
|
alias ℕℕ : Natural.
|
||||||
variable x : Natural.
|
variable x : Natural.
|
||||||
print environment 1.
|
print environment 1.
|
||||||
set::option pp::unicode false.
|
set_option pp::unicode false.
|
||||||
print environment 1.
|
print environment 1.
|
||||||
set::option pp::unicode true.
|
set_option pp::unicode true.
|
||||||
print environment 1.
|
print environment 1.
|
||||||
alias NN : Natural.
|
alias NN : Natural.
|
||||||
print environment 2.
|
print environment 2.
|
||||||
alias ℕℕℕ : Natural.
|
alias ℕℕℕ : Natural.
|
||||||
print environment 3.
|
print environment 3.
|
||||||
set::option pp::unicode false.
|
set_option pp::unicode false.
|
||||||
print environment 3.
|
print environment 3.
|
||||||
pop::scope
|
pop_scope
|
|
@ -10,9 +10,9 @@ variable n : Nat
|
||||||
variable m : Nat
|
variable m : Nat
|
||||||
print n + m
|
print n + m
|
||||||
print n + x + m
|
print n + x + m
|
||||||
set::option lean::pp::coercion true
|
set_option lean::pp::coercion true
|
||||||
print n + x + m + 10
|
print n + x + m + 10
|
||||||
print x + n + m + 10
|
print x + n + m + 10
|
||||||
print n + m + 10 + x
|
print n + m + 10 + x
|
||||||
set::option lean::pp::notation false
|
set_option lean::pp::notation false
|
||||||
print n + m + 10 + x
|
print n + m + 10 + x
|
||||||
|
|
|
@ -7,7 +7,7 @@ variable x : Real
|
||||||
variable i : Int
|
variable i : Int
|
||||||
variable n : Nat
|
variable n : Nat
|
||||||
print x + i + 1 + n
|
print x + i + 1 + n
|
||||||
set::option lean::pp::coercion true
|
set_option lean::pp::coercion true
|
||||||
print x + i + 1 + n
|
print x + i + 1 + n
|
||||||
print x * i + x
|
print x * i + x
|
||||||
print x - i + x - x >= 0
|
print x - i + x - x >= 0
|
||||||
|
|
|
@ -4,7 +4,7 @@ eval 8 div 4
|
||||||
eval 7 div 3
|
eval 7 div 3
|
||||||
eval 7 mod 3
|
eval 7 mod 3
|
||||||
print -8 mod 3
|
print -8 mod 3
|
||||||
set::option lean::pp::notation false
|
set_option lean::pp::notation false
|
||||||
print -8 mod 3
|
print -8 mod 3
|
||||||
eval -8 mod 3
|
eval -8 mod 3
|
||||||
eval (-8 div 3)*3 + (-8 mod 3)
|
eval (-8 div 3)*3 + (-8 mod 3)
|
|
@ -1,5 +1,5 @@
|
||||||
import Int.
|
import Int.
|
||||||
set::option pp::unicode false
|
set_option pp::unicode false
|
||||||
print 3 | 6
|
print 3 | 6
|
||||||
eval 3 | 6
|
eval 3 | 6
|
||||||
eval 3 | 7
|
eval 3 | 7
|
||||||
|
@ -9,5 +9,5 @@ variable x : Int
|
||||||
eval x | 3
|
eval x | 3
|
||||||
eval 3 | x
|
eval 3 | x
|
||||||
eval 6 | 3
|
eval 6 | 3
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
print 3 | x
|
print 3 | x
|
|
@ -11,6 +11,6 @@ eval |x + 1| > 0
|
||||||
variable y : Int
|
variable y : Int
|
||||||
eval |x + y|
|
eval |x + y|
|
||||||
print |x + y| > x
|
print |x + y| > x
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
print |x + y| > x
|
print |x + y| > x
|
||||||
print |x + y| + |y + x| > x
|
print |x + y| + |y + x| > x
|
|
@ -1,5 +1,5 @@
|
||||||
set::option pp::implicit true.
|
set_option pp::implicit true.
|
||||||
set::option pp::colors false.
|
set_option pp::colors false.
|
||||||
variable N : Type.
|
variable N : Type.
|
||||||
|
|
||||||
definition T (a : N) (f : _ -> _) (H : f a == a) : f (f _) == f _ :=
|
definition T (a : N) (f : _ -> _) (H : f a == a) : f (f _) == f _ :=
|
||||||
|
|
|
@ -8,6 +8,6 @@ definition n3 : list Int := cons 10 nil
|
||||||
definition n4 : list Int := nil
|
definition n4 : list Int := nil
|
||||||
definition n5 : _ := cons 10 nil
|
definition n5 : _ := cons 10 nil
|
||||||
|
|
||||||
set::option pp::coercion true
|
set_option pp::coercion true
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
print environment 1.
|
print environment 1.
|
|
@ -1,5 +1,5 @@
|
||||||
set::option pp::implicit true.
|
set_option pp::implicit true.
|
||||||
set::option pp::colors false.
|
set_option pp::colors false.
|
||||||
variable N : Type.
|
variable N : Type.
|
||||||
|
|
||||||
check
|
check
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import cast
|
import cast
|
||||||
set::option pp::colors false
|
set_option pp::colors false
|
||||||
|
|
||||||
check fun (A A': TypeM)
|
check fun (A A': TypeM)
|
||||||
(B : A -> TypeM)
|
(B : A -> TypeM)
|
||||||
|
|
|
@ -8,25 +8,25 @@ print g a a
|
||||||
variable b : R
|
variable b : R
|
||||||
print g a b
|
print g a b
|
||||||
print g b a
|
print g b a
|
||||||
set::option lean::pp::coercion true
|
set_option lean::pp::coercion true
|
||||||
print g a a
|
print g a a
|
||||||
print g a b
|
print g a b
|
||||||
print g b a
|
print g b a
|
||||||
set::option lean::pp::coercion false
|
set_option lean::pp::coercion false
|
||||||
variable S : Type
|
variable S : Type
|
||||||
variable s : S
|
variable s : S
|
||||||
variable r : S
|
variable r : S
|
||||||
variable h : S -> S -> S
|
variable h : S -> S -> S
|
||||||
infixl 10 ++ : g
|
infixl 10 ++ : g
|
||||||
infixl 10 ++ : h
|
infixl 10 ++ : h
|
||||||
set::option lean::pp::notation false
|
set_option lean::pp::notation false
|
||||||
print a ++ b ++ a
|
print a ++ b ++ a
|
||||||
print r ++ s ++ r
|
print r ++ s ++ r
|
||||||
check a ++ b ++ a
|
check a ++ b ++ a
|
||||||
check r ++ s ++ r
|
check r ++ s ++ r
|
||||||
set::option lean::pp::coercion true
|
set_option lean::pp::coercion true
|
||||||
print a ++ b ++ a
|
print a ++ b ++ a
|
||||||
print r ++ s ++ r
|
print r ++ s ++ r
|
||||||
set::option lean::pp::notation true
|
set_option lean::pp::notation true
|
||||||
print a ++ b ++ a
|
print a ++ b ++ a
|
||||||
print r ++ s ++ r
|
print r ++ s ++ r
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
-- set::option default configuration for tests
|
-- set_option default configuration for tests
|
||||||
set::option pp::colors false
|
set_option pp::colors false
|
||||||
set::option pp::unicode true
|
set_option pp::unicode true
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
Imported 'tactic'
|
Imported 'tactic'
|
||||||
Proved: T1
|
Proved: T1
|
||||||
Proved: T2
|
Proved: T2
|
||||||
theorem T2 (a b : Bool) (H : a ∨ b) : b ∨ a := or::elim H (λ H : a, or::intror b H) (λ H : b, or::introl H a)
|
theorem T2 (a b : Bool) (H : a ∨ b) : b ∨ a := or_elim H (λ H : a, or_intror b H) (λ H : b, or_introl H a)
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
variables a b c : Bool
|
variables a b c : Bool
|
||||||
axiom H : a \/ b
|
axiom H : a \/ b
|
||||||
theorem T (a b : Bool) : a \/ b → b \/ a.
|
theorem T (a b : Bool) : a \/ b → b \/ a.
|
||||||
apply (or::elim H).
|
apply (or_elim H).
|
||||||
apply or::intror.
|
apply or_intror.
|
||||||
exact.
|
exact.
|
||||||
apply or::introl.
|
apply or_introl.
|
||||||
exact.
|
exact.
|
||||||
done.
|
done.
|
|
@ -15,13 +15,13 @@ check fun (A B : Type) (a : _) (b : _) (C : Type), my_eq C a b.
|
||||||
variable a : Bool
|
variable a : Bool
|
||||||
variable b : Bool
|
variable b : Bool
|
||||||
variable H : a /\ b
|
variable H : a /\ b
|
||||||
theorem t1 : b := (fun H1, and::intro H1 (and::eliml H)).
|
theorem t1 : b := (fun H1, and_intro H1 (and_eliml H)).
|
||||||
|
|
||||||
theorem t2 : a = b := trans (refl a) (refl b).
|
theorem t2 : a = b := trans (refl a) (refl b).
|
||||||
|
|
||||||
check f Bool Bool.
|
check f Bool Bool.
|
||||||
|
|
||||||
theorem pierce (a b : Bool) : ((a -> b) -> a) -> a :=
|
theorem pierce (a b : Bool) : ((a -> b) -> a) -> a :=
|
||||||
λ H, or::elim (EM a)
|
λ H, or_elim (EM a)
|
||||||
(λ H_a, H)
|
(λ H_a, H)
|
||||||
(λ H_na, NotImp1 (MT H H_na))
|
(λ H_na, NotImp1 (MT H H_na))
|
||||||
|
|
|
@ -54,4 +54,4 @@ Failed to solve
|
||||||
?M::0
|
?M::0
|
||||||
Bool
|
Bool
|
||||||
Bool
|
Bool
|
||||||
Error (line: 25, pos: 19) unknown identifier 'EM'
|
Error (line: 25, pos: 18) unknown identifier 'EM'
|
||||||
|
|
|
@ -8,5 +8,5 @@ variable R {A A' : Type} {B : A -> Type} {B' : A' -> Type} (H : (forall x : A, B
|
||||||
theorem R2 : forall (A1 A2 B1 B2 : Type) (H : (A1 -> B1) = (A2 -> B2)) (a : A1), B1 = B2 :=
|
theorem R2 : forall (A1 A2 B1 B2 : Type) (H : (A1 -> B1) = (A2 -> B2)) (a : A1), B1 = B2 :=
|
||||||
fun A1 A2 B1 B2 H a, R H a
|
fun A1 A2 B1 B2 H a, R H a
|
||||||
|
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
print environment 7.
|
print environment 7.
|
||||||
|
|
|
@ -8,5 +8,5 @@ variable R {A A' : Type} {B : A -> Type} {B' : A' -> Type} (H : (forall x : A, B
|
||||||
theorem R2 : forall (A1 A2 B1 B2 : Type), ((A1 -> B1) = (A2 -> B2)) -> A1 -> (B1 = B2) :=
|
theorem R2 : forall (A1 A2 B1 B2 : Type), ((A1 -> B1) = (A2 -> B2)) -> A1 -> (B1 = B2) :=
|
||||||
fun A1 A2 B1 B2 H a, R H a
|
fun A1 A2 B1 B2 H a, R H a
|
||||||
|
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
print environment 7.
|
print environment 7.
|
||||||
|
|
|
@ -17,5 +17,5 @@ theorem T2 : (fun (x1 : A) (x2 : B), F1 x1 x2) = F2 := funext (fun a, (funext (f
|
||||||
theorem T3 : F1 = (fun (x1 : A) (x2 : B), F2 x1 x2) := funext (fun a, (funext (fun b, H a b)))
|
theorem T3 : F1 = (fun (x1 : A) (x2 : B), F2 x1 x2) := funext (fun a, (funext (fun b, H a b)))
|
||||||
theorem T4 : (fun (x1 : A) (x2 : B), F1 x1 x2) = (fun (x1 : A) (x2 : B), F2 x1 x2) := funext (fun a, (funext (fun b, H a b)))
|
theorem T4 : (fun (x1 : A) (x2 : B), F1 x1 x2) = (fun (x1 : A) (x2 : B), F2 x1 x2) := funext (fun a, (funext (fun b, H a b)))
|
||||||
print environment 4
|
print environment 4
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
print environment 4
|
print environment 4
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
variable x : Nat
|
variable x : Nat
|
||||||
|
|
||||||
set::opaque x true.
|
set_opaque x true.
|
||||||
|
|
||||||
print "before import"
|
print "before import"
|
||||||
(*
|
(*
|
||||||
|
@ -26,4 +25,3 @@ print "before load3"
|
||||||
local env = get_environment()
|
local env = get_environment()
|
||||||
env:load("fake2.olean")
|
env:load("fake2.olean")
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
Set: pp::colors
|
Set: pp::colors
|
||||||
Set: pp::unicode
|
Set: pp::unicode
|
||||||
Assumed: x
|
Assumed: x
|
||||||
Error (line: 4, pos: 0) set_opaque failed, 'x' is not a definition
|
Error (line: 3, pos: 0) set_opaque failed, 'x' is not a definition
|
||||||
before import
|
before import
|
||||||
Error (line: 12, pos: 0) file 'tstblafoo.lean' not found in the LEAN_PATH
|
Error (line: 11, pos: 0) file 'tstblafoo.lean' not found in the LEAN_PATH
|
||||||
before load1
|
before load1
|
||||||
Error (line: 18, pos: 0) failed to open file 'tstblafoo.lean'
|
Error (line: 17, pos: 0) failed to open file 'tstblafoo.lean'
|
||||||
before load2
|
before load2
|
||||||
Error (line: 24, pos: 0) corrupted binary file
|
Error (line: 23, pos: 0) corrupted binary file
|
||||||
before load3
|
before load3
|
||||||
Error (line: 30, pos: 0) file 'fake2.olean' does not seem to be a valid object Lean file
|
Error (line: 28, pos: 0) file 'fake2.olean' does not seem to be a valid object Lean file
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Int.
|
import Int.
|
||||||
variable i : Int
|
variable i : Int
|
||||||
check i = 0
|
check i = 0
|
||||||
set::option pp::coercion true
|
set_option pp::coercion true
|
||||||
check i = 0
|
check i = 0
|
||||||
|
|
|
@ -4,5 +4,5 @@ variable nil {A : Type} : List A
|
||||||
variable cons {A : Type} (head : A) (tail : List A) : List A
|
variable cons {A : Type} (head : A) (tail : List A) : List A
|
||||||
variable l : List Int.
|
variable l : List Int.
|
||||||
check l = nil.
|
check l = nil.
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
check l = nil.
|
check l = nil.
|
||||||
|
|
|
@ -7,5 +7,5 @@ variable v3 : Vector (0 + n)
|
||||||
axiom H1 : v1 == v2
|
axiom H1 : v1 == v2
|
||||||
axiom H2 : v2 == v3
|
axiom H2 : v2 == v3
|
||||||
check htrans H1 H2
|
check htrans H1 H2
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
check htrans H1 H2
|
check htrans H1 H2
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
-- comment
|
-- comment
|
||||||
print true
|
print true
|
||||||
set::option lean::pp::notation false
|
set_option lean::pp::notation false
|
||||||
print true && false
|
print true && false
|
||||||
set::option pp::unicode false
|
set_option pp::unicode false
|
||||||
print true && false
|
print true && false
|
||||||
variable a : Bool
|
variable a : Bool
|
||||||
variable a : Bool
|
variable a : Bool
|
||||||
|
@ -12,7 +12,7 @@ variable A : Type
|
||||||
check a && A
|
check a && A
|
||||||
print environment 1
|
print environment 1
|
||||||
print options
|
print options
|
||||||
set::option lean::p::notation true
|
set_option lean::p::notation true
|
||||||
set::option lean::pp::notation 10
|
set_option lean::pp::notation 10
|
||||||
set::option lean::pp::notation true
|
set_option lean::pp::notation true
|
||||||
print a && b
|
print a && b
|
||||||
|
|
|
@ -19,7 +19,7 @@ Arguments types:
|
||||||
A : Type
|
A : Type
|
||||||
variable A : Type
|
variable A : Type
|
||||||
(lean::pp::notation := false, pp::unicode := false, pp::colors := false)
|
(lean::pp::notation := false, pp::unicode := false, pp::colors := false)
|
||||||
Error (line: 15, pos: 12) unknown option 'lean::p::notation', type 'Help Options.' for list of available options
|
Error (line: 15, pos: 11) unknown option 'lean::p::notation', type 'Help Options.' for list of available options
|
||||||
Error (line: 16, pos: 31) invalid option value, given option is not an integer
|
Error (line: 16, pos: 30) invalid option value, given option is not an integer
|
||||||
Set: lean::pp::notation
|
Set: lean::pp::notation
|
||||||
a /\ b
|
a /\ b
|
||||||
|
|
|
@ -5,5 +5,5 @@ variable a : T
|
||||||
check myeq _ true a
|
check myeq _ true a
|
||||||
variable myeq2 {A:Type} (a b : A) : Bool
|
variable myeq2 {A:Type} (a b : A) : Bool
|
||||||
infix 50 === : myeq2
|
infix 50 === : myeq2
|
||||||
set::option lean::pp::implicit true
|
set_option lean::pp::implicit true
|
||||||
check true === a
|
check true === a
|
|
@ -2,5 +2,5 @@ import Int.
|
||||||
variable a : Int
|
variable a : Int
|
||||||
variable P : Int -> Int -> Bool
|
variable P : Int -> Int -> Bool
|
||||||
axiom H : P a a
|
axiom H : P a a
|
||||||
theorem T : exists x : Int, P a a := exists::intro a H.
|
theorem T : exists x : Int, P a a := exists_intro a H.
|
||||||
print environment 1.
|
print environment 1.
|
|
@ -5,4 +5,4 @@
|
||||||
Assumed: P
|
Assumed: P
|
||||||
Assumed: H
|
Assumed: H
|
||||||
Proved: T
|
Proved: T
|
||||||
theorem T : ∃ x : ℤ, P a a := exists::intro a H
|
theorem T : ∃ x : ℤ, P a a := exists_intro a H
|
||||||
|
|
|
@ -6,13 +6,13 @@ variable g : Int -> Int
|
||||||
axiom H1 : P (f a (g a)) (f a (g a))
|
axiom H1 : P (f a (g a)) (f a (g a))
|
||||||
axiom H2 : P (f (g a) (g a)) (f (g a) (g a))
|
axiom H2 : P (f (g a) (g a)) (f (g a) (g a))
|
||||||
axiom H3 : P (f (g a) (g a)) (g a)
|
axiom H3 : P (f (g a) (g a)) (g a)
|
||||||
theorem T1 : exists x y : Int, P (f y x) (f y x) := exists::intro _ (exists::intro _ H1)
|
theorem T1 : exists x y : Int, P (f y x) (f y x) := exists_intro _ (exists_intro _ H1)
|
||||||
theorem T2 : exists x : Int, P (f x (g x)) (f x (g x)) := exists::intro _ H1
|
theorem T2 : exists x : Int, P (f x (g x)) (f x (g x)) := exists_intro _ H1
|
||||||
theorem T3 : exists x : Int, P (f x x) (f x x) := exists::intro _ H2
|
theorem T3 : exists x : Int, P (f x x) (f x x) := exists_intro _ H2
|
||||||
theorem T4 : exists x : Int, P (f (g a) x) (f x x) := exists::intro _ H2
|
theorem T4 : exists x : Int, P (f (g a) x) (f x x) := exists_intro _ H2
|
||||||
theorem T5 : exists x : Int, P x x := exists::intro _ H2
|
theorem T5 : exists x : Int, P x x := exists_intro _ H2
|
||||||
theorem T6 : exists x y : Int, P x y := exists::intro _ (exists::intro _ H3)
|
theorem T6 : exists x y : Int, P x y := exists_intro _ (exists_intro _ H3)
|
||||||
theorem T7 : exists x : Int, P (f x x) x := exists::intro _ H3
|
theorem T7 : exists x : Int, P (f x x) x := exists_intro _ H3
|
||||||
theorem T8 : exists x y : Int, P (f x x) y := exists::intro _ (exists::intro _ H3)
|
theorem T8 : exists x y : Int, P (f x x) y := exists_intro _ (exists_intro _ H3)
|
||||||
|
|
||||||
print environment 8.
|
print environment 8.
|
|
@ -16,11 +16,11 @@
|
||||||
Proved: T6
|
Proved: T6
|
||||||
Proved: T7
|
Proved: T7
|
||||||
Proved: T8
|
Proved: T8
|
||||||
theorem T1 : ∃ x y : ℤ, P (f y x) (f y x) := exists::intro (g a) (exists::intro a H1)
|
theorem T1 : ∃ x y : ℤ, P (f y x) (f y x) := exists_intro (g a) (exists_intro a H1)
|
||||||
theorem T2 : ∃ x : ℤ, P (f x (g x)) (f x (g x)) := exists::intro a H1
|
theorem T2 : ∃ x : ℤ, P (f x (g x)) (f x (g x)) := exists_intro a H1
|
||||||
theorem T3 : ∃ x : ℤ, P (f x x) (f x x) := exists::intro (g a) H2
|
theorem T3 : ∃ x : ℤ, P (f x x) (f x x) := exists_intro (g a) H2
|
||||||
theorem T4 : ∃ x : ℤ, P (f (g a) x) (f x x) := exists::intro (g a) H2
|
theorem T4 : ∃ x : ℤ, P (f (g a) x) (f x x) := exists_intro (g a) H2
|
||||||
theorem T5 : ∃ x : ℤ, P x x := exists::intro (f (g a) (g a)) H2
|
theorem T5 : ∃ x : ℤ, P x x := exists_intro (f (g a) (g a)) H2
|
||||||
theorem T6 : ∃ x y : ℤ, P x y := exists::intro (f (g a) (g a)) (exists::intro (g a) H3)
|
theorem T6 : ∃ x y : ℤ, P x y := exists_intro (f (g a) (g a)) (exists_intro (g a) H3)
|
||||||
theorem T7 : ∃ x : ℤ, P (f x x) x := exists::intro (g a) H3
|
theorem T7 : ∃ x : ℤ, P (f x x) x := exists_intro (g a) H3
|
||||||
theorem T8 : ∃ x y : ℤ, P (f x x) y := exists::intro (g a) (exists::intro (g a) H3)
|
theorem T8 : ∃ x y : ℤ, P (f x x) y := exists_intro (g a) (exists_intro (g a) H3)
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
import Int.
|
import Int.
|
||||||
variable P : Int -> Int -> Bool
|
variable P : Int -> Int -> Bool
|
||||||
|
|
||||||
set::opaque exists false.
|
set_opaque exists false.
|
||||||
|
|
||||||
theorem T1 (R1 : not (exists x y, P x y)) : forall x y, not (P x y) :=
|
theorem T1 (R1 : not (exists x y, P x y)) : forall x y, not (P x y) :=
|
||||||
fun a b,
|
fun a b,
|
||||||
not::not::elim (not::not::elim R1 a) b
|
not_not_elim (not_not_elim R1 a) b
|
||||||
|
|
||||||
axiom Ax : forall x, exists y, P x y
|
axiom Ax : forall x, exists y, P x y
|
||||||
|
|
||||||
theorem T2 : exists x y, P x y :=
|
theorem T2 : exists x y, P x y :=
|
||||||
refute (fun R : not (exists x y, P x y),
|
refute (fun R : not (exists x y, P x y),
|
||||||
let L1 : forall x y, not (P x y) := fun a b, (not::not::elim ((not::not::elim R) a)) b,
|
let L1 : forall x y, not (P x y) := fun a b, (not_not_elim ((not_not_elim R) a)) b,
|
||||||
L2 : exists y, P 0 y := Ax 0
|
L2 : exists y, P 0 y := Ax 0
|
||||||
in exists::elim L2 (fun (w : Int) (H : P 0 w),
|
in exists_elim L2 (fun (w : Int) (H : P 0 w),
|
||||||
absurd H (L1 0 w))).
|
absurd H (L1 0 w))).
|
||||||
|
|
||||||
theorem T3 (A : (Type U)) (P : A -> A -> Bool) (a : A) (H1 : forall x, exists y, P x y) : exists x y, P x y :=
|
theorem T3 (A : (Type U)) (P : A -> A -> Bool) (a : A) (H1 : forall x, exists y, P x y) : exists x y, P x y :=
|
||||||
refute (fun R : not (exists x y, P x y),
|
refute (fun R : not (exists x y, P x y),
|
||||||
let L1 : forall x y, not (P x y) := fun a b,
|
let L1 : forall x y, not (P x y) := fun a b,
|
||||||
(not::not::elim ((not::not::elim R) a)) b,
|
(not_not_elim ((not_not_elim R) a)) b,
|
||||||
L2 : exists y, P a y := H1 a
|
L2 : exists y, P a y := H1 a
|
||||||
in exists::elim L2 (fun (w : A) (H : P a w),
|
in exists_elim L2 (fun (w : A) (H : P a w),
|
||||||
absurd H (L1 a w))).
|
absurd H (L1 a w))).
|
||||||
|
|
|
@ -3,14 +3,14 @@ variables a b c : N
|
||||||
variables P : N -> N -> N -> Bool
|
variables P : N -> N -> N -> Bool
|
||||||
axiom H3 : P a b c
|
axiom H3 : P a b c
|
||||||
|
|
||||||
theorem T1 : exists x y z : N, P x y z := exists::@intro N (fun x : N, exists y z : N, P x y z) a
|
theorem T1 : exists x y z : N, P x y z := @exists_intro N (fun x : N, exists y z : N, P x y z) a
|
||||||
(exists::@intro N _ b
|
(@exists_intro N _ b
|
||||||
(exists::@intro N (fun z : N, P a b z) c H3))
|
(@exists_intro N (fun z : N, P a b z) c H3))
|
||||||
|
|
||||||
theorem T2 : exists x y z : N, P x y z := exists::intro a (exists::intro b (exists::intro c H3))
|
theorem T2 : exists x y z : N, P x y z := exists_intro a (exists_intro b (exists_intro c H3))
|
||||||
|
|
||||||
theorem T3 : exists x y z : N, P x y z := exists::intro _ (exists::intro _ (exists::intro _ H3))
|
theorem T3 : exists x y z : N, P x y z := exists_intro _ (exists_intro _ (exists_intro _ H3))
|
||||||
|
|
||||||
theorem T4 (H : P a a b) : exists x y z, P x y z := exists::intro _ (exists::intro _ (exists::intro _ H))
|
theorem T4 (H : P a a b) : exists x y z, P x y z := exists_intro _ (exists_intro _ (exists_intro _ H))
|
||||||
|
|
||||||
print environment 4
|
print environment 4
|
|
@ -11,11 +11,11 @@
|
||||||
Proved: T3
|
Proved: T3
|
||||||
Proved: T4
|
Proved: T4
|
||||||
theorem T1 : ∃ x y z : N, P x y z :=
|
theorem T1 : ∃ x y z : N, P x y z :=
|
||||||
exists::@intro
|
@exists_intro
|
||||||
N
|
N
|
||||||
(λ x : N, ∃ y z : N, P x y z)
|
(λ x : N, ∃ y z : N, P x y z)
|
||||||
a
|
a
|
||||||
(exists::@intro N (λ y : N, ∃ z : N, P a y z) b (exists::@intro N (λ z : N, P a b z) c H3))
|
(@exists_intro N (λ y : N, ∃ z : N, P a y z) b (@exists_intro N (λ z : N, P a b z) c H3))
|
||||||
theorem T2 : ∃ x y z : N, P x y z := exists::intro a (exists::intro b (exists::intro c H3))
|
theorem T2 : ∃ x y z : N, P x y z := exists_intro a (exists_intro b (exists_intro c H3))
|
||||||
theorem T3 : ∃ x y z : N, P x y z := exists::intro a (exists::intro b (exists::intro c H3))
|
theorem T3 : ∃ x y z : N, P x y z := exists_intro a (exists_intro b (exists_intro c H3))
|
||||||
theorem T4 (H : P a a b) : ∃ x y z : N, P x y z := exists::intro a (exists::intro a (exists::intro b H))
|
theorem T4 (H : P a a b) : ∃ x y z : N, P x y z := exists_intro a (exists_intro a (exists_intro b H))
|
||||||
|
|
|
@ -2,6 +2,6 @@ variable N : Type
|
||||||
variables a b c : N
|
variables a b c : N
|
||||||
variables P : N -> N -> N -> Bool
|
variables P : N -> N -> N -> Bool
|
||||||
|
|
||||||
theorem T1 (f : N -> N) (H : P (f a) b (f (f c))) : exists x y z, P x y z := exists::intro _ (exists::intro _ (exists::intro _ H))
|
theorem T1 (f : N -> N) (H : P (f a) b (f (f c))) : exists x y z, P x y z := exists_intro _ (exists_intro _ (exists_intro _ H))
|
||||||
|
|
||||||
print environment 1.
|
print environment 1.
|
||||||
|
|
|
@ -7,4 +7,4 @@
|
||||||
Assumed: P
|
Assumed: P
|
||||||
Proved: T1
|
Proved: T1
|
||||||
theorem T1 (f : N → N) (H : P (f a) b (f (f c))) : ∃ x y z : N, P x y z :=
|
theorem T1 (f : N → N) (H : P (f a) b (f (f c))) : ∃ x y z : N, P x y z :=
|
||||||
exists::intro (f a) (exists::intro b (exists::intro (f (f c)) H))
|
exists_intro (f a) (exists_intro b (exists_intro (f (f c)) H))
|
||||||
|
|
|
@ -3,6 +3,6 @@ variable P : Int -> Int -> Int -> Bool
|
||||||
axiom Ax1 : exists x y z, P x y z
|
axiom Ax1 : exists x y z, P x y z
|
||||||
axiom Ax2 : forall x y z, not (P x y z)
|
axiom Ax2 : forall x y z, not (P x y z)
|
||||||
theorem T : false :=
|
theorem T : false :=
|
||||||
exists::elim Ax1 (fun a H1, exists::elim H1 (fun b H2, exists::elim H2 (fun (c : Int) (H3 : P a b c),
|
exists_elim Ax1 (fun a H1, exists_elim H1 (fun b H2, exists_elim H2 (fun (c : Int) (H3 : P a b c),
|
||||||
let notH3 : not (P a b c) := Ax2 a b c
|
let notH3 : not (P a b c) := Ax2 a b c
|
||||||
in absurd H3 notH3)))
|
in absurd H3 notH3)))
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
set::option pp::colors false
|
set_option pp::colors false
|
||||||
variable N : Type
|
variable N : Type
|
||||||
variables a b c : N
|
variables a b c : N
|
||||||
variables P : N -> N -> N -> Bool
|
variables P : N -> N -> N -> Bool
|
||||||
|
|
||||||
set::opaque exists false.
|
set_opaque exists false.
|
||||||
set::opaque not false.
|
set_opaque not false.
|
||||||
|
|
||||||
theorem T1 (f : N -> N) (H : P (f a) b (f (f c))) : exists x y z, P x y z := exists::intro _ (exists::intro _ (exists::intro _ H))
|
theorem T1 (f : N -> N) (H : P (f a) b (f (f c))) : exists x y z, P x y z := exists_intro _ (exists_intro _ (exists_intro _ H))
|
||||||
|
|
||||||
print environment 1.
|
print environment 1.
|
||||||
|
|
|
@ -8,4 +8,4 @@
|
||||||
Assumed: P
|
Assumed: P
|
||||||
Proved: T1
|
Proved: T1
|
||||||
theorem T1 (f : N → N) (H : P (f a) b (f (f c))) : ∃ x y z : N, P x y z :=
|
theorem T1 (f : N → N) (H : P (f a) b (f (f c))) : ∃ x y z : N, P x y z :=
|
||||||
exists::intro (f a) (exists::intro b (exists::intro (f (f c)) H))
|
exists_intro (f a) (exists_intro b (exists_intro (f (f c)) H))
|
||||||
|
|
|
@ -3,22 +3,22 @@ variable P : Int -> Int -> Bool
|
||||||
|
|
||||||
theorem T1 (R1 : not (exists x y, P x y)) : forall x y, not (P x y) :=
|
theorem T1 (R1 : not (exists x y, P x y)) : forall x y, not (P x y) :=
|
||||||
fun a b,
|
fun a b,
|
||||||
(not::exists::elim (not::exists::elim R1 a)) b
|
(not_exists_elim (not_exists_elim R1 a)) b
|
||||||
|
|
||||||
axiom Ax : forall x, exists y, P x y
|
axiom Ax : forall x, exists y, P x y
|
||||||
|
|
||||||
theorem T2 : exists x y, P x y :=
|
theorem T2 : exists x y, P x y :=
|
||||||
refute (fun R : not (exists x y, P x y),
|
refute (fun R : not (exists x y, P x y),
|
||||||
let L1 : forall x y, not (P x y) := fun a b,
|
let L1 : forall x y, not (P x y) := fun a b,
|
||||||
(not::exists::elim ((not::exists::elim R) a)) b,
|
(not_exists_elim ((not_exists_elim R) a)) b,
|
||||||
L2 : exists y, P 0 y := Ax 0
|
L2 : exists y, P 0 y := Ax 0
|
||||||
in exists::elim L2 (fun (w : Int) (H : P 0 w),
|
in exists_elim L2 (fun (w : Int) (H : P 0 w),
|
||||||
absurd H (L1 0 w))).
|
absurd H (L1 0 w))).
|
||||||
|
|
||||||
theorem T3 (A : (Type U)) (P : A -> A -> Bool) (a : A) (H1 : forall x, exists y, P x y) : exists x y, P x y :=
|
theorem T3 (A : (Type U)) (P : A -> A -> Bool) (a : A) (H1 : forall x, exists y, P x y) : exists x y, P x y :=
|
||||||
refute (fun R : not (exists x y, P x y),
|
refute (fun R : not (exists x y, P x y),
|
||||||
let L1 : forall x y, not (P x y) := fun a b,
|
let L1 : forall x y, not (P x y) := fun a b,
|
||||||
(not::exists::elim ((not::exists::elim R) a)) b,
|
(not_exists_elim ((not_exists_elim R) a)) b,
|
||||||
L2 : exists y, P a y := H1 a
|
L2 : exists y, P a y := H1 a
|
||||||
in exists::elim L2 (fun (w : A) (H : P a w),
|
in exists_elim L2 (fun (w : A) (H : P a w),
|
||||||
absurd H ((L1 a) w))).
|
absurd H ((L1 a) w))).
|
||||||
|
|
|
@ -6,7 +6,7 @@ print forall a b, f a b > 0
|
||||||
variable g : Int -> Real -> Int
|
variable g : Int -> Real -> Int
|
||||||
print forall a b, g a b > 0
|
print forall a b, g a b > 0
|
||||||
print forall a b, g a (f a b) > 0
|
print forall a b, g a (f a b) > 0
|
||||||
set::option pp::coercion true
|
set_option pp::coercion true
|
||||||
print forall a b, g a (f a b) > 0
|
print forall a b, g a (f a b) > 0
|
||||||
print fun a, a + 1
|
print fun a, a + 1
|
||||||
print fun a b, a + b
|
print fun a b, a + b
|
||||||
|
|
|
@ -8,6 +8,6 @@ check g 10 20 true
|
||||||
check let r : Real -> Real -> Real := g 10 20
|
check let r : Real -> Real -> Real := g 10 20
|
||||||
in r
|
in r
|
||||||
check g 10
|
check g 10
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
check let r : Real -> Real -> Real := g 10 20
|
check let r : Real -> Real -> Real := g 10 20
|
||||||
in r
|
in r
|
||||||
|
|
|
@ -5,7 +5,7 @@ variable f : Int -> Int -> Int
|
||||||
variable g : Int -> Int -> Int -> Int
|
variable g : Int -> Int -> Int -> Int
|
||||||
notation 10 _ ++ _ : f
|
notation 10 _ ++ _ : f
|
||||||
notation 10 _ ++ _ : g
|
notation 10 _ ++ _ : g
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
print (10 ++ 20)
|
print (10 ++ 20)
|
||||||
print (10 ++ 20) 10
|
print (10 ++ 20) 10
|
||||||
|
|
|
@ -4,8 +4,8 @@ infixl 65 + : f
|
||||||
print true + false
|
print true + false
|
||||||
print 10 + 20
|
print 10 + 20
|
||||||
print 10 + (- 20)
|
print 10 + (- 20)
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
set::option pp::coercion true
|
set_option pp::coercion true
|
||||||
print true + false
|
print true + false
|
||||||
print 10 + 20
|
print 10 + 20
|
||||||
print 10 + (- 20)
|
print 10 + (- 20)
|
||||||
|
|
|
@ -4,9 +4,9 @@ notation 100 _ ; _ ; _ : f
|
||||||
notation 100 _ ; _ ; _ : g
|
notation 100 _ ; _ ; _ : g
|
||||||
check 10 ; true ; false
|
check 10 ; true ; false
|
||||||
check 10 ; 10 ; true
|
check 10 ; 10 ; true
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
check 10 ; true ; false
|
check 10 ; true ; false
|
||||||
check 10 ; 10 ; true
|
check 10 ; 10 ; true
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
check 10 ; true ; false
|
check 10 ; true ; false
|
||||||
check 10 ; 10 ; true
|
check 10 ; 10 ; true
|
||||||
|
|
|
@ -10,14 +10,14 @@ theorem Comm1 : ∀ n m, n + m = m + n
|
||||||
:= Induction
|
:= Induction
|
||||||
_ -- I use a placeholder because I do not want to write the P
|
_ -- I use a placeholder because I do not want to write the P
|
||||||
(λ m, -- Base case
|
(λ m, -- Base case
|
||||||
calc 0 + m = m : add::zerol m
|
calc 0 + m = m : add_zerol m
|
||||||
... = m + 0 : symm (add::zeror m))
|
... = m + 0 : symm (add_zeror m))
|
||||||
(λ n, -- Inductive case
|
(λ n, -- Inductive case
|
||||||
λ (iH : ∀ m, n + m = m + n),
|
λ (iH : ∀ m, n + m = m + n),
|
||||||
λ m,
|
λ m,
|
||||||
calc n + 1 + m = (n + m) + 1 : add::succl n m
|
calc n + 1 + m = (n + m) + 1 : add_succl n m
|
||||||
... = (m + n) + 1 : { iH m }
|
... = (m + n) + 1 : { iH m }
|
||||||
... = m + (n + 1) : symm (add::succr m n))
|
... = m + (n + 1) : symm (add_succr m n))
|
||||||
|
|
||||||
-- indunction on m
|
-- indunction on m
|
||||||
|
|
||||||
|
@ -25,13 +25,13 @@ theorem Comm2 : ∀ n m, n + m = m + n
|
||||||
:= λ n,
|
:= λ n,
|
||||||
Induction
|
Induction
|
||||||
_
|
_
|
||||||
(calc n + 0 = n : add::zeror n
|
(calc n + 0 = n : add_zeror n
|
||||||
... = 0 + n : symm (add::zerol n))
|
... = 0 + n : symm (add_zerol n))
|
||||||
(λ m,
|
(λ m,
|
||||||
λ (iH : n + m = m + n),
|
λ (iH : n + m = m + n),
|
||||||
calc n + (m + 1) = (n + m) + 1 : add::succr n m
|
calc n + (m + 1) = (n + m) + 1 : add_succr n m
|
||||||
... = (m + n) + 1 : { iH }
|
... = (m + n) + 1 : { iH }
|
||||||
... = (m + 1) + n : symm (add::succl m n))
|
... = (m + 1) + n : symm (add_succl m n))
|
||||||
|
|
||||||
|
|
||||||
print environment 1
|
print environment 1
|
|
@ -9,6 +9,6 @@ theorem Comm2 : ∀ n m : ℕ, n + m = m + n :=
|
||||||
λ n : ℕ,
|
λ n : ℕ,
|
||||||
Induction
|
Induction
|
||||||
(λ x : ℕ, n + x == x + n)
|
(λ x : ℕ, n + x == x + n)
|
||||||
(Nat::add::zeror n ⋈ symm (Nat::add::zerol n))
|
(Nat::add_zeror n ⋈ symm (Nat::add_zerol n))
|
||||||
(λ (m : ℕ) (iH : n + m = m + n),
|
(λ (m : ℕ) (iH : n + m = m + n),
|
||||||
Nat::add::succr n m ⋈ subst (refl (n + m + 1)) iH ⋈ symm (Nat::add::succl m n))
|
Nat::add_succr n m ⋈ subst (refl (n + m + 1)) iH ⋈ symm (Nat::add_succl m n))
|
||||||
|
|
|
@ -10,9 +10,9 @@ theorem Comm1 : ∀ n m, n + m = m + n
|
||||||
:= Induction
|
:= Induction
|
||||||
_ -- I use a placeholder because I do not want to write the P
|
_ -- I use a placeholder because I do not want to write the P
|
||||||
(λ m, -- Base case
|
(λ m, -- Base case
|
||||||
calc 0 + m = m : add::zerol m
|
calc 0 + m = m : add_zerol m
|
||||||
... = m + 0 : symm (add::zeror m))
|
... = m + 0 : symm (add_zeror m))
|
||||||
(λ n iH m, -- Inductive case
|
(λ n iH m, -- Inductive case
|
||||||
calc n + 1 + m = (n + m) + 1 : add::succl n m
|
calc n + 1 + m = (n + m) + 1 : add_succl n m
|
||||||
... = (m + n) + 1 : { iH } -- Error is here
|
... = (m + n) + 1 : { iH } -- Error is here
|
||||||
... = m + (n + 1) : symm (add::succr m n))
|
... = m + (n + 1) : symm (add_succr m n))
|
||||||
|
|
|
@ -9,6 +9,6 @@ Failed to solve
|
||||||
Induction
|
Induction
|
||||||
with arguments:
|
with arguments:
|
||||||
?M::3
|
?M::3
|
||||||
λ m : ℕ, Nat::add::zerol m ⋈ symm (Nat::add::zeror m)
|
λ m : ℕ, Nat::add_zerol m ⋈ symm (Nat::add_zeror m)
|
||||||
λ (n : ℕ) (iH : ?M::3 n) (m : ℕ),
|
λ (n : ℕ) (iH : ?M::3 n) (m : ℕ),
|
||||||
Nat::add::succl n m ⋈ subst (refl (n + m + 1)) iH ⋈ symm (Nat::add::succr m n)
|
Nat::add_succl n m ⋈ subst (refl (n + m + 1)) iH ⋈ symm (Nat::add_succr m n)
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
-- set::option default configuration for tests
|
-- set_option default configuration for tests
|
||||||
set::option pp::colors false
|
set_option pp::colors false
|
||||||
set::option pp::unicode true
|
set_option pp::unicode true
|
||||||
|
|
|
@ -28,7 +28,7 @@ theorem T3 (A B : Bool) : A /\ B -> B /\ A :=
|
||||||
in _.
|
in _.
|
||||||
conj_hyp. exact. done.
|
conj_hyp. exact. done.
|
||||||
conj_hyp. exact. done.
|
conj_hyp. exact. done.
|
||||||
apply and::intro. exact. done.
|
apply and_intro. exact. done.
|
||||||
|
|
||||||
theorem T4 (A B : Bool) : A /\ B -> B /\ A :=
|
theorem T4 (A B : Bool) : A /\ B -> B /\ A :=
|
||||||
fun assumption : A /\ B,
|
fun assumption : A /\ B,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Set: pp::unicode
|
Set: pp::unicode
|
||||||
Proved: T1
|
Proved: T1
|
||||||
theorem T1 (A B : Bool) (assumption : A ∧ B) : B ∧ A :=
|
theorem T1 (A B : Bool) (assumption : A ∧ B) : B ∧ A :=
|
||||||
let lemma1 : A := and::eliml assumption, lemma2 : B := and::elimr assumption in and::intro lemma2 lemma1
|
let lemma1 : A := and_eliml assumption, lemma2 : B := and_elimr assumption in and_intro lemma2 lemma1
|
||||||
# Proof state:
|
# Proof state:
|
||||||
A : Bool, B : Bool, assumption : A ∧ B ⊢ A
|
A : Bool, B : Bool, assumption : A ∧ B ⊢ A
|
||||||
## Proof state:
|
## Proof state:
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
Set: pp::unicode
|
Set: pp::unicode
|
||||||
Proved: T1
|
Proved: T1
|
||||||
theorem T1 (A B : Bool) (assumption : A ∧ B) : B ∧ A :=
|
theorem T1 (A B : Bool) (assumption : A ∧ B) : B ∧ A :=
|
||||||
let lemma1 := and::eliml assumption, lemma2 := and::elimr assumption in and::intro lemma2 lemma1
|
let lemma1 := and_eliml assumption, lemma2 := and_elimr assumption in and_intro lemma2 lemma1
|
||||||
#
|
#
|
|
@ -12,5 +12,5 @@ a : Bool, b : Bool, H : b ⊢ b
|
||||||
## Proof state:
|
## Proof state:
|
||||||
no goals
|
no goals
|
||||||
## Proved: T2
|
## Proved: T2
|
||||||
# theorem T2 (a b : Bool) (H : b) : a ∨ b := or::intror a H
|
# theorem T2 (a b : Bool) (H : b) : a ∨ b := or_intror a H
|
||||||
#
|
#
|
|
@ -1,5 +1,5 @@
|
||||||
(* import("tactic.lua") *)
|
(* import("tactic.lua") *)
|
||||||
theorem T1 (a b : Bool) : a → b → a /\ b.
|
theorem T1 (a b : Bool) : a → b → a /\ b.
|
||||||
apply and::intro.
|
apply and_intro.
|
||||||
exact.
|
exact.
|
||||||
done.
|
done.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(* import("tactic.lua") *)
|
(* import("tactic.lua") *)
|
||||||
set::option tactic::proof_state::goal_names true.
|
set_option tactic::proof_state::goal_names true.
|
||||||
theorem T (a : Bool) : a → a /\ a.
|
theorem T (a : Bool) : a → a /\ a.
|
||||||
apply and::intro.
|
apply and_intro.
|
||||||
exact.
|
exact.
|
||||||
done.
|
done.
|
||||||
|
|
|
@ -12,7 +12,7 @@ theorem T1 (A B : Bool) : A /\ B → B /\ A :=
|
||||||
conj_hyp.
|
conj_hyp.
|
||||||
exact.
|
exact.
|
||||||
done.
|
done.
|
||||||
apply and::intro.
|
apply and_intro.
|
||||||
exact.
|
exact.
|
||||||
done.
|
done.
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,5 @@ check let a : Nat := 10 in a + 1
|
||||||
eval let a : Nat := 20 in a + 10
|
eval let a : Nat := 20 in a + 10
|
||||||
eval let a := 20 in a + 10
|
eval let a := 20 in a + 10
|
||||||
check let a : Int := 20 in a + 10
|
check let a : Int := 20 in a + 10
|
||||||
set::option pp::coercion true
|
set_option pp::coercion true
|
||||||
print let a : Int := 20 in a + 10
|
print let a : Int := 20 in a + 10
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
theorem simple (p q r : Bool) : (p → q) ∧ (q → r) → p → r :=
|
theorem simple (p q r : Bool) : (p → q) ∧ (q → r) → p → r :=
|
||||||
λ H_pq_qr H_p,
|
λ H_pq_qr H_p,
|
||||||
let P_pq : (p → q) := and::eliml H_pq_qr,
|
let P_pq : (p → q) := and_eliml H_pq_qr,
|
||||||
P_qr : (q → r) := and::elimr H_pq_qr,
|
P_qr : (q → r) := and_elimr H_pq_qr,
|
||||||
P_q : q := P_pq H_p
|
P_q : q := P_pq H_p
|
||||||
in P_qr P_q
|
in P_qr P_q
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
Set: pp::unicode
|
Set: pp::unicode
|
||||||
Proved: simple
|
Proved: simple
|
||||||
theorem simple (p q r : Bool) (H_pq_qr : (p → q) ∧ (q → r)) (H_p : p) : r :=
|
theorem simple (p q r : Bool) (H_pq_qr : (p → q) ∧ (q → r)) (H_p : p) : r :=
|
||||||
let P_pq : p → q := and::eliml H_pq_qr, P_qr : q → r := and::elimr H_pq_qr, P_q : q := P_pq H_p in P_qr P_q
|
let P_pq : p → q := and_eliml H_pq_qr, P_qr : q → r := and_elimr H_pq_qr, P_q : q := P_pq H_p in P_qr P_q
|
||||||
|
|
|
@ -2,8 +2,8 @@ import Int.
|
||||||
|
|
||||||
variable magic : forall (H : Bool), H
|
variable magic : forall (H : Bool), H
|
||||||
|
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
set::option pp::coercion true
|
set_option pp::coercion true
|
||||||
print let a : Int := 1,
|
print let a : Int := 1,
|
||||||
H : a > 0 := magic (a > 0)
|
H : a > 0 := magic (a > 0)
|
||||||
in H
|
in H
|
|
@ -41,7 +41,7 @@ let a := 10,
|
||||||
v2 : vector Int a := v1
|
v2 : vector Int a := v1
|
||||||
in v2
|
in v2
|
||||||
|
|
||||||
set::option pp::coercion true
|
set_option pp::coercion true
|
||||||
|
|
||||||
print
|
print
|
||||||
let a := 10,
|
let a := 10,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Int.
|
import Int.
|
||||||
variable x : Int
|
variable x : Int
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
(*
|
(*
|
||||||
print(get_options())
|
print(get_options())
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import cast
|
import cast
|
||||||
set::option pp::colors false
|
set_option pp::colors false
|
||||||
|
|
||||||
check fun (A A': TypeM)
|
check fun (A A': TypeM)
|
||||||
(a : A)
|
(a : A)
|
||||||
(b : A')
|
(b : A')
|
||||||
(L2 : A' == A),
|
(L2 : A' == A),
|
||||||
let b' : A := cast L2 b,
|
let b' : A := cast L2 b,
|
||||||
L3 : b == b' := cast::eq L2 b
|
L3 : b == b' := cast_eq L2 b
|
||||||
in L3
|
in L3
|
||||||
|
|
||||||
check fun (A A': TypeM)
|
check fun (A A': TypeM)
|
||||||
|
@ -18,10 +18,10 @@ check fun (A A': TypeM)
|
||||||
(b : A')
|
(b : A')
|
||||||
(H2 : f == g)
|
(H2 : f == g)
|
||||||
(H3 : a == b),
|
(H3 : a == b),
|
||||||
let L1 : A == A' := type::eq H3,
|
let L1 : A == A' := type_eq H3,
|
||||||
L2 : A' == A := symm L1,
|
L2 : A' == A := symm L1,
|
||||||
b' : A := cast L2 b,
|
b' : A := cast L2 b,
|
||||||
L3 : b == b' := cast::eq L2 b,
|
L3 : b == b' := cast_eq L2 b,
|
||||||
L4 : a == b' := htrans H3 L3,
|
L4 : a == b' := htrans H3 L3,
|
||||||
L5 : f a == f b' := congr2 f L4
|
L5 : f a == f b' := congr2 f L4
|
||||||
in L5
|
in L5
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Set: pp::unicode
|
Set: pp::unicode
|
||||||
Imported 'cast'
|
Imported 'cast'
|
||||||
Set: pp::colors
|
Set: pp::colors
|
||||||
λ (A A' : TypeM) (a : A) (b : A') (L2 : A' == A), let b' : A := cast L2 b, L3 : b == b' := cast::eq L2 b in L3 :
|
λ (A A' : TypeM) (a : A) (b : A') (L2 : A' == A), let b' : A := cast L2 b, L3 : b == b' := cast_eq L2 b in L3 :
|
||||||
∀ (A A' : TypeM) (a : A) (b : A') (L2 : A' == A), b == cast L2 b
|
∀ (A A' : TypeM) (a : A) (b : A') (L2 : A' == A), b == cast L2 b
|
||||||
λ (A A' : TypeM)
|
λ (A A' : TypeM)
|
||||||
(B : A → TypeM)
|
(B : A → TypeM)
|
||||||
|
@ -13,10 +13,10 @@
|
||||||
(b : A')
|
(b : A')
|
||||||
(H2 : f == g)
|
(H2 : f == g)
|
||||||
(H3 : a == b),
|
(H3 : a == b),
|
||||||
let L1 : A == A' := type::eq H3,
|
let L1 : A == A' := type_eq H3,
|
||||||
L2 : A' == A := symm L1,
|
L2 : A' == A := symm L1,
|
||||||
b' : A := cast L2 b,
|
b' : A := cast L2 b,
|
||||||
L3 : b == b' := cast::eq L2 b,
|
L3 : b == b' := cast_eq L2 b,
|
||||||
L4 : a == b' := htrans H3 L3,
|
L4 : a == b' := htrans H3 L3,
|
||||||
L5 : f a == f b' := congr2 f L4
|
L5 : f a == f b' := congr2 f L4
|
||||||
in L5 :
|
in L5 :
|
||||||
|
@ -29,4 +29,4 @@
|
||||||
(b : A')
|
(b : A')
|
||||||
(H2 : f == g)
|
(H2 : f == g)
|
||||||
(H3 : a == b),
|
(H3 : a == b),
|
||||||
f a == f (cast (symm (type::eq H3)) b)
|
f a == f (cast (symm (type_eq H3)) b)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import Int
|
import Int
|
||||||
import tactic
|
import tactic
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
set::option pp::coercion true
|
set_option pp::coercion true
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
variable vector (A : Type) (sz : Nat) : Type
|
variable vector (A : Type) (sz : Nat) : Type
|
||||||
variable read {A : Type} {sz : Nat} (v : vector A sz) (i : Nat) (H : i < sz) : A
|
variable read {A : Type} {sz : Nat} (v : vector A sz) (i : Nat) (H : i < sz) : A
|
||||||
variable V1 : vector Int 10
|
variable V1 : vector Int 10
|
||||||
|
|
|
@ -4,7 +4,7 @@ variable g : N -> N -> N
|
||||||
infixl 10 ++ : f
|
infixl 10 ++ : f
|
||||||
infixl 10 ++ : g
|
infixl 10 ++ : g
|
||||||
print true ++ false ++ true
|
print true ++ false ++ true
|
||||||
set::option lean::pp::notation false
|
set_option lean::pp::notation false
|
||||||
print true ++ false ++ true
|
print true ++ false ++ true
|
||||||
variable a : N
|
variable a : N
|
||||||
variable b : N
|
variable b : N
|
||||||
|
|
|
@ -10,8 +10,8 @@ coercion t2r
|
||||||
variable f : T -> R -> T
|
variable f : T -> R -> T
|
||||||
variable a : T
|
variable a : T
|
||||||
variable b : R
|
variable b : R
|
||||||
set::option lean::pp::coercion true
|
set_option lean::pp::coercion true
|
||||||
set::option lean::pp::notation false
|
set_option lean::pp::notation false
|
||||||
print f a b
|
print f a b
|
||||||
print f b a
|
print f b a
|
||||||
variable g : R -> T -> R
|
variable g : R -> T -> R
|
||||||
|
|
|
@ -6,7 +6,7 @@ scope
|
||||||
variables a b c : Int
|
variables a b c : Int
|
||||||
variable f : Int -> Int
|
variable f : Int -> Int
|
||||||
eval f a
|
eval f a
|
||||||
pop::scope
|
pop_scope
|
||||||
|
|
||||||
eval f a -- should produce an error
|
eval f a -- should produce an error
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ print environment 1
|
||||||
scope
|
scope
|
||||||
infixl 100 ++ : Int::add
|
infixl 100 ++ : Int::add
|
||||||
check 10 ++ 20
|
check 10 ++ 20
|
||||||
pop::scope
|
pop_scope
|
||||||
|
|
||||||
check 10 ++ 20 -- should produce an error
|
check 10 ++ 20 -- should produce an error
|
||||||
|
|
||||||
pop::scope -- should produce an error
|
pop_scope -- should produce an error
|
|
@ -1,3 +1,3 @@
|
||||||
variables a b : Bool
|
variables a b : Bool
|
||||||
axiom H : a /\ b
|
axiom H : a /\ b
|
||||||
theorem T : a := refute (fun R, absurd (and::eliml H) R)
|
theorem T : a := refute (fun R, absurd (and_eliml H) R)
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
set::option pp::colors false
|
set_option pp::colors false
|
||||||
print "===BEGIN ENVIRONMENT==="
|
print "===BEGIN ENVIRONMENT==="
|
||||||
print environment
|
print environment
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
-- set::option default configuration for tests
|
-- set_option default configuration for tests
|
||||||
set::option pp::colors false
|
set_option pp::colors false
|
||||||
set::option pp::unicode true
|
set_option pp::unicode true
|
||||||
|
|
|
@ -3,6 +3,6 @@ definition f1 (f : Int -> Int) (x : Int) : Int := f (f (f (f x)))
|
||||||
definition f2 (f : Int -> Int) (x : Int) : Int := f1 (f1 (f1 (f1 f))) x
|
definition f2 (f : Int -> Int) (x : Int) : Int := f1 (f1 (f1 (f1 f))) x
|
||||||
definition f3 (f : Int -> Int) (x : Int) : Int := f1 (f2 (f2 f)) x
|
definition f3 (f : Int -> Int) (x : Int) : Int := f1 (f2 (f2 f)) x
|
||||||
variable f : Int -> Int.
|
variable f : Int -> Int.
|
||||||
set::option pp::width 80.
|
set_option pp::width 80.
|
||||||
set::option lean::pp::max_depth 2000.
|
set_option lean::pp::max_depth 2000.
|
||||||
eval f3 f 0.
|
eval f3 f 0.
|
|
@ -4,7 +4,7 @@ variable n : Nat
|
||||||
axiom H1 : a + a + a = 10
|
axiom H1 : a + a + a = 10
|
||||||
axiom H2 : a = n
|
axiom H2 : a = n
|
||||||
theorem T : a + n + a = 10 := subst H1 H2
|
theorem T : a + n + a = 10 := subst H1 H2
|
||||||
set::option pp::coercion true
|
set_option pp::coercion true
|
||||||
set::option pp::notation false
|
set_option pp::notation false
|
||||||
set::option pp::implicit true
|
set_option pp::implicit true
|
||||||
print environment 1.
|
print environment 1.
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
Assumed: p
|
Assumed: p
|
||||||
Assumed: q
|
Assumed: q
|
||||||
Assumed: r
|
Assumed: r
|
||||||
theorem T1 (H : p) (H::1 : q) : p ∧ q := and::intro H H::1
|
theorem T1 (H : p) (H::1 : q) : p ∧ q := and_intro H H::1
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue