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 geq based on leq
ecsolticia.codeberg.page
6 months ago
d8d3f3b0
36574ce3
+19
2 changed files
expand all
collapse all
unified
split
src
lib.rs
main.rs
+15
src/lib.rs
···
26
26
eq::Eq,
27
27
28
28
leq::Leq,
29
29
+
geq::Geq,
29
30
30
31
add::Add,
31
32
mul::Times,
···
61
62
// Induction
62
63
// A <= B means S(A) <= S(B)
63
64
impl<A: Nat, B: Nat> Leq<Succ<B>> for Succ<A>
65
65
+
where
66
66
+
A: Leq<B>
67
67
+
{}
68
68
+
}
69
69
+
70
70
+
pub mod geq {
71
71
+
use super::prelude::*;
72
72
+
73
73
+
pub trait Geq<A: Nat> {
74
74
+
fn geq() -> () {}
75
75
+
}
76
76
+
77
77
+
// If A <= B then B => A
78
78
+
impl<A: Nat, B: Nat> Geq<A> for B
64
79
where
65
80
A: Leq<B>
66
81
{}
+4
src/main.rs
···
1
1
+
#![recursion_limit = "132"]
2
2
+
1
3
use rspeano::prelude::*;
2
4
3
5
fn five_plus_five_is_ten() {
···
70
72
// _5::even();
71
73
72
74
<_3 as Leq<_4>>::leq();
75
75
+
<_4 as Geq<_4>>::geq();
76
76
+
<_10 as Geq<_5>>::geq();
73
77
// fails:
74
78
// <_3 as Leq<_2>>::leq();
75
79
}