Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Proost
Manage
Activity
Members
Labels
Plan
Issues
33
Issue boards
Milestones
Code
Merge requests
18
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
loutr
Proost
Commits
bf91f788
Commit
bf91f788
authored
2 years ago
by
arthur-adjedj
Browse files
Options
Downloads
Patches
Plain Diff
feat : add UniverseLevel
parent
328982eb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kernel/src/universe.rs
+56
-0
56 additions, 0 deletions
kernel/src/universe.rs
with
56 additions
and
0 deletions
kernel/src/universe.rs
0 → 100644
+
56
−
0
View file @
bf91f788
use
derive_more
::{
Display
};
#[derive(Clone,
Debug,
Default,
Display,
PartialEq,
Eq)]
pub
enum
UniverseLevel
{
#[default]
UnivZero
,
UnivSucc
(
Box
<
UniverseLevel
>
),
#[display(fmt
=
"max {} {}"
,
_0,
_1)]
UnivMax
(
Box
<
UniverseLevel
>
,
Box
<
UniverseLevel
>
),
UnivVar
(
usize
)
}
use
UniverseLevel
::
*
;
impl
UniverseLevel
{
fn
normalize
(
self
)
->
Self
{
match
self
{
UnivMax
(
box
UnivSucc
(
u1
),
box
UnivSucc
(
u2
))
=>
UnivSucc
(
box
UnivMax
(
u1
,
u2
)),
UnivMax
(
box
u1
,
box
UnivZero
)
|
UnivMax
(
box
UnivZero
,
box
u1
)
=>
u1
,
UnivMax
(
u1
,
u2
)
if
u1
.clone
()
.normalize
()
==
u2
.clone
()
.normalize
()
=>
u1
.clone
()
.normalize
(),
_
=>
self
}
}
fn
shift
(
self
,
n
:
usize
)
->
Self
{
match
self
{
UnivZero
=>
self
,
UnivSucc
(
u
)
=>
UnivSucc
(
box
u
.shift
(
n
)),
UnivMax
(
u1
,
u2
)
=>
UnivMax
(
box
u1
.shift
(
n
),
box
u2
.shift
(
n
)),
UnivVar
(
k
)
if
k
>
n
=>
UnivVar
(
k
-
1
),
_
=>
self
}
}
fn
substitute
(
self
,
n
:
usize
)
->
Self
{
}
fn
geq
(
self
,
u2
:
UniverseLevel
,
n
:
u64
)
->
bool
{
match
(
self
,
u2
)
{
(
UnivZero
,
_
)
if
n
>=
0
=>
true
,
(
_
,
_
)
if
self
==
u2
&&
n
>=
0
=>
true
,
(
UnivSucc
(
l
),
_
)
if
l
.geq
(
u2
,
n
-
1
)
=>
true
,
(
_
,
UnivSucc
(
box
l
))
if
self
.geq
(
l
,
n
+
1
)
=>
true
,
(
_
,
UnivMax
(
box
l1
,
box
l2
))
if
self
.geq
(
l1
,
n
)
||
self
.geq
(
l2
,
n
)
=>
true
,
(
UnivMax
(
box
l1
,
box
l2
),
_
)
if
l1
.geq
(
u2
,
n
)
&&
l2
.geq
(
u2
,
n
)
=>
true
}
}
pub
fn
is_eq
(
self
,
u2
:
UniverseLevel
)
->
bool
{
self
.geq
(
u2
,
0
)
&&
u2
.geq
(
self
,
0
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment