feat(builtin/Nat): add basic axioms and theorems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
b2a8f4118d
commit
aa009b6b05
2 changed files with 36 additions and 2 deletions
|
@ -4,7 +4,6 @@ Variable Nat : Type.
|
||||||
Alias ℕ : Nat.
|
Alias ℕ : Nat.
|
||||||
|
|
||||||
Namespace Nat.
|
Namespace Nat.
|
||||||
|
|
||||||
Builtin numeral.
|
Builtin numeral.
|
||||||
|
|
||||||
Builtin add : Nat → Nat → Nat.
|
Builtin add : Nat → Nat → Nat.
|
||||||
|
@ -30,9 +29,44 @@ Infix 50 > : gt.
|
||||||
Definition id (a : Nat) := a.
|
Definition id (a : Nat) := a.
|
||||||
Notation 55 | _ | : id.
|
Notation 55 | _ | : id.
|
||||||
|
|
||||||
|
Axiom PlusZero (a : Nat) : a + 0 = a.
|
||||||
|
Axiom PlusSucc (a b : Nat) : a + (b + 1) = (a + b) + 1.
|
||||||
|
Axiom Induction {P : Nat -> Bool} (Hb : P 0) (Hi : Pi (n : Nat) (H : P n), P (n + 1)) (a : Nat) : P a.
|
||||||
|
|
||||||
|
Theorem ZeroPlus (a : Nat) : 0 + a = a
|
||||||
|
:= Induction (show 0 + 0 = 0, Trivial)
|
||||||
|
(fun (n : Nat) (H : 0 + n = n),
|
||||||
|
(show 0 + (n + 1) = n + 1,
|
||||||
|
let L1 : 0 + (n + 1) = (0 + n) + 1 := PlusSucc 0 n
|
||||||
|
in Subst L1 H))
|
||||||
|
a.
|
||||||
|
|
||||||
|
Theorem SuccPlus (a b : Nat) : (a + 1) + b = (a + b) + 1
|
||||||
|
:= Induction (show (a + 1) + 0 = (a + 0) + 1,
|
||||||
|
(Subst (PlusZero (a + 1)) (Symm (PlusZero a))))
|
||||||
|
(fun (n : Nat) (H : (a + 1) + n = (a + n) + 1),
|
||||||
|
(show (a + 1) + (n + 1) = (a + (n + 1)) + 1,
|
||||||
|
let L1 : (a + 1) + (n + 1) = ((a + 1) + n) + 1 := PlusSucc (a + 1) n,
|
||||||
|
L2 : (a + 1) + (n + 1) = ((a + n) + 1) + 1 := Subst L1 H,
|
||||||
|
L3 : (a + n) + 1 = a + (n + 1) := Symm (PlusSucc a n)
|
||||||
|
in Subst L2 L3))
|
||||||
|
b.
|
||||||
|
|
||||||
|
Theorem PlusComm (a b : Nat) : a + b = b + a
|
||||||
|
:= Induction (show a + 0 = 0 + a,
|
||||||
|
let L1 : a + 0 = a := PlusZero a,
|
||||||
|
L2 : a = 0 + a := Symm (ZeroPlus a)
|
||||||
|
in Trans L1 L2)
|
||||||
|
(fun (n : Nat) (H : a + n = n + a),
|
||||||
|
(show a + (n + 1) = (n + 1) + a,
|
||||||
|
let L1 : a + (n + 1) = (a + n) + 1 := PlusSucc a n,
|
||||||
|
L2 : a + (n + 1) = (n + a) + 1 := Subst L1 H,
|
||||||
|
L3 : (n + a) + 1 = (n + 1) + a := Symm (SuccPlus n a)
|
||||||
|
in Trans L2 L3))
|
||||||
|
b.
|
||||||
|
|
||||||
SetOpaque ge true.
|
SetOpaque ge true.
|
||||||
SetOpaque lt true.
|
SetOpaque lt true.
|
||||||
SetOpaque gt true.
|
SetOpaque gt true.
|
||||||
SetOpaque id true.
|
SetOpaque id true.
|
||||||
|
|
||||||
EndNamespace.
|
EndNamespace.
|
Binary file not shown.
Loading…
Reference in a new issue