tangled
alpha
login
or
join now
ecsolticia.codeberg.page
/
rspeano
1
fork
atom
Compile-time construction of Peano axioms-based natural numbers and addition, multiplication, and exponentiation defined through them within Rust. (Mirrored from Codeberg)
1
fork
atom
overview
issues
pulls
pipelines
impl leq
ecsolticia.codeberg.page
6 months ago
c063782a
084e8ab0
+27
1 changed file
expand all
collapse all
unified
split
src
lib.rs
+27
src/lib.rs
···
20
Nat,
21
Succ,
22
_0,
0
23
eq::Eq,
24
eq::ProofEq,
0
0
0
0
25
add::Add,
26
mul::Times,
27
exp::Exp
···
40
41
// Define equality of naturals
42
impl<T: Nat> Eq<T, T> for ProofEq<T, T> {}
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
43
}
44
45
pub mod add {
···
20
Nat,
21
Succ,
22
_0,
23
+
24
eq::Eq,
25
eq::ProofEq,
26
+
27
+
leq::Leq,
28
+
leq::ProofLeq,
29
+
30
add::Add,
31
mul::Times,
32
exp::Exp
···
45
46
// Define equality of naturals
47
impl<T: Nat> Eq<T, T> for ProofEq<T, T> {}
48
+
}
49
+
50
+
pub mod leq {
51
+
use super::prelude::*;
52
+
53
+
pub trait Leq<A: Nat, B: Nat> {
54
+
fn check() -> () {}
55
+
}
56
+
57
+
pub struct ProofLeq<A: Nat, B: Nat>(A, B);
58
+
59
+
// Base case
60
+
// 0 <= N for every N
61
+
impl<A: Nat> Leq<_0, A> for ProofLeq<_0, A> {}
62
+
63
+
// Induction
64
+
// A <= B means S(A) <= S(B)
65
+
impl<A: Nat, B: Nat> Leq<Succ<A>, Succ<B>> for
66
+
ProofLeq<Succ<A>, Succ<B>>
67
+
where
68
+
ProofLeq<A, B>: Leq<A, B>
69
+
{}
70
}
71
72
pub mod add {