Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Refinedrust Dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Gäher
Refinedrust Dev
Merge requests
!55
Refactor `coq` crate
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Refactor `coq` crate
radium/coq-scripts
into
main
Overview
16
Commits
16
Pipelines
15
Changes
30
Merged
Vincent Lafeychine
requested to merge
radium/coq-scripts
into
main
9 months ago
Overview
7
Commits
16
Pipelines
15
Changes
30
Expand
0
0
Merge request reports
Compare
main
version 14
b7125100
7 months ago
version 13
a05eeeda
7 months ago
version 12
b112f584
7 months ago
version 11
62f3befa
7 months ago
version 10
11a4ef9b
7 months ago
version 9
854b389f
7 months ago
version 8
ab317b1c
7 months ago
version 7
6b7063f7
8 months ago
version 6
22e3e8c6
8 months ago
version 5
cbbab0f7
8 months ago
version 4
d7af645c
8 months ago
version 3
8306a110
8 months ago
version 2
b4244575
9 months ago
version 1
8b61e8a1
9 months ago
main (base)
and
latest version
latest version
ab0a69d9
16 commits,
5 months ago
version 14
b7125100
15 commits,
7 months ago
version 13
a05eeeda
15 commits,
7 months ago
version 12
b112f584
15 commits,
7 months ago
version 11
62f3befa
15 commits,
7 months ago
version 10
11a4ef9b
15 commits,
7 months ago
version 9
854b389f
15 commits,
7 months ago
version 8
ab317b1c
15 commits,
7 months ago
version 7
6b7063f7
14 commits,
8 months ago
version 6
22e3e8c6
14 commits,
8 months ago
version 5
cbbab0f7
14 commits,
8 months ago
version 4
d7af645c
12 commits,
8 months ago
version 3
8306a110
9 commits,
8 months ago
version 2
b4244575
9 commits,
9 months ago
version 1
8b61e8a1
9 commits,
9 months ago
30 files
+
2176
−
1392
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
30
Search (e.g. *.vue) (Ctrl+P)
rr_frontend/radium/src/coq/binder.rs
0 → 100644
+
142
−
0
Options
//! The [implicit arguments], and [binders].
//!
//! [implicit arguments]: https://coq.inria.fr/doc/v8.20/refman/language/extensions/implicit-arguments.html#implicit-arguments
//! [binders]: https://coq.inria.fr/doc/v8.20/refman/language/core/assumptions.html#binders
use
std
::
fmt
;
use
derive_more
::
Display
;
use
crate
::
coq
::
term
;
use
crate
::
display_list
;
/// A [binder].
///
/// [binder]: https://coq.inria.fr/doc/v8.20/refman/language/core/assumptions.html#grammar-token-binder
#[derive(Clone,
Eq,
PartialEq,
Debug,
Display)]
pub
enum
Binder
{
#[display(
"({}: {})"
,
self
.
get_name(),
_1)]
Default
(
Option
<
String
>
,
term
::
Type
),
#[display(
"{}"
,
_0)]
Generalizing
(
Generalizing
),
}
impl
Binder
{
#[must_use]
pub
const
fn
new
(
name
:
Option
<
String
>
,
ty
:
term
::
Type
)
->
Self
{
Self
::
Default
(
name
,
ty
)
}
#[must_use]
pub
const
fn
new_generalized
(
kind
:
Kind
,
name
:
Option
<
String
>
,
ty
:
term
::
Type
)
->
Self
{
Self
::
Generalizing
(
Generalizing
{
kind
,
name
,
ty
})
}
#[must_use]
pub
(
crate
)
fn
get_name
(
&
self
)
->
String
{
match
self
{
Self
::
Default
(
name
,
_
)
=>
name
.clone
()
.unwrap_or_else
(||
"_"
.to_owned
()),
Self
::
Generalizing
(
g
)
=>
g
.name
.clone
()
.unwrap_or_else
(||
"_"
.to_owned
()),
}
}
pub
(
crate
)
const
fn
get_name_ref
(
&
self
)
->
&
Option
<
String
>
{
match
self
{
Self
::
Default
(
name
,
_
)
=>
name
,
Self
::
Generalizing
(
g
)
=>
&
g
.name
,
}
}
pub
(
crate
)
const
fn
get_type
(
&
self
)
->
&
term
::
Type
{
match
self
{
Self
::
Default
(
_
,
ty
)
=>
ty
,
Self
::
Generalizing
(
g
)
=>
&
g
.ty
,
}
}
#[must_use]
pub
(
crate
)
const
fn
is_implicit
(
&
self
)
->
bool
{
matches!
(
self
,
Self
::
Generalizing
(
_
))
}
#[must_use]
pub
(
crate
)
fn
is_dependent_on_sigma
(
&
self
)
->
bool
{
let
term
::
Type
::
Literal
(
lit
)
=
self
.get_type
()
else
{
return
false
;
};
lit
.contains
(
'Σ'
)
}
#[must_use]
pub
fn
set_name
(
self
,
name
:
String
)
->
Self
{
match
self
{
Self
::
Default
(
_
,
ty
)
=>
Self
::
Default
(
Some
(
name
),
ty
),
Self
::
Generalizing
(
g
)
=>
Self
::
Generalizing
(
Generalizing
{
name
:
Some
(
name
),
..
g
}),
}
}
}
#[derive(Clone,
Eq,
PartialEq,
Debug)]
pub
enum
Kind
{
/// `()
Implicit
,
/// `{}
MaxImplicit
,
}
/// [Implicit generalization] binders.
///
/// [Implicit generalization]: https://coq.inria.fr/doc/v8.20/refman/language/extensions/implicit-arguments.html#grammar-token-generalizing_binder
#[derive(Clone,
Eq,
PartialEq,
Debug)]
pub
struct
Generalizing
{
kind
:
Kind
,
name
:
Option
<
String
>
,
ty
:
term
::
Type
,
}
impl
fmt
::
Display
for
Generalizing
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
match
(
&
self
.kind
,
&
self
.name
)
{
(
Kind
::
Implicit
,
Some
(
name
))
=>
write!
(
f
,
"`({} : !{})"
,
name
,
self
.ty
),
(
Kind
::
Implicit
,
None
)
=>
write!
(
f
,
"`(!{})"
,
self
.ty
),
(
Kind
::
MaxImplicit
,
Some
(
name
))
=>
write!
(
f
,
"`{{{} : !{}}}"
,
name
,
self
.ty
),
(
Kind
::
MaxImplicit
,
None
)
=>
write!
(
f
,
"`{{!{}}}"
,
self
.ty
),
}
}
}
/// A Rocq pattern, e.g., "x" or "'(x, y)".
pub
type
Pattern
=
String
;
#[allow(clippy::module_name_repetitions)]
#[derive(Clone,
Eq,
PartialEq,
Debug,
Display)]
#[display(
"{}"
,
display_list
!
(_0,
" "
))]
pub
struct
BinderList
(
pub
Vec
<
Binder
>
);
impl
BinderList
{
#[must_use]
pub
const
fn
new
(
params
:
Vec
<
Binder
>
)
->
Self
{
Self
(
params
)
}
#[must_use]
pub
const
fn
empty
()
->
Self
{
Self
(
vec!
[])
}
pub
fn
append
(
&
mut
self
,
params
:
Vec
<
Binder
>
)
{
self
.0
.extend
(
params
);
}
/// Make using terms for this list of binders
#[must_use]
pub
fn
make_using_terms
(
&
self
)
->
Vec
<
term
::
Gallina
>
{
self
.0
.iter
()
.map
(|
x
|
term
::
Gallina
::
Literal
(
format!
(
"{}"
,
x
.get_name
())))
.collect
()
}
}
Loading