Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
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
Commits
e4a382a7
Verified
Commit
e4a382a7
authored
9 months ago
by
Vincent Lafeychine
Browse files
Options
Downloads
Patches
Plain Diff
chore(coq/assertions): Simplification
parent
36648b40
No related branches found
No related tags found
1 merge request
!55
Refactor `coq` crate
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rr_frontend/radium/src/coq.rs
+8
-8
8 additions, 8 deletions
rr_frontend/radium/src/coq.rs
rr_frontend/radium/src/specs.rs
+26
-20
26 additions, 20 deletions
rr_frontend/radium/src/specs.rs
with
34 additions
and
28 deletions
rr_frontend/radium/src/coq.rs
+
8
−
8
View file @
e4a382a7
...
...
@@ -728,14 +728,14 @@ impl Display for Definition {
}
#[derive(Clone,
Eq,
PartialEq,
Debug,
Display)]
pub
enum
TopLevelAssertion
{
pub
enum
TopLevelAssertion
<
'a
>
{
/// A declaration of a Coq Inductive
#[display(
"{}"
,
_0)]
InductiveDecl
(
Inductive
),
InductiveDecl
(
&
'a
Inductive
),
/// A declaration of a Coq instance
#[display(
"{}"
,
_0)]
InstanceDecl
(
InstanceDecl
),
InstanceDecl
(
&
'a
InstanceDecl
),
/// A declaration of a Coq record
#[display(
"{}"
,
_0)]
...
...
@@ -751,11 +751,11 @@ pub enum TopLevelAssertion {
/// A Coq comment
#[display(
"(* {} *)"
,
_0)]
Comment
(
String
),
Comment
(
&
'a
str
),
/// A Coq section
#[display(
"Section {}.
\n
{}End{}."
,
_0,
Indented::new(_1),
_0)]
Section
(
String
,
TopLevelAssertions
),
Section
(
String
,
TopLevelAssertions
<
'a
>
),
/// A Coq section start
#[display(
"Section {}."
,
_0)]
...
...
@@ -784,15 +784,15 @@ impl<T: Display> Display for Indented<T> {
#[derive(Clone,
Eq,
PartialEq,
Debug,
Display)]
#[display(
"{}"
,
display_list
!
(_0,
"
\n
"
))]
pub
struct
TopLevelAssertions
(
pub
Vec
<
TopLevelAssertion
>
);
pub
struct
TopLevelAssertions
<
'a
>
(
pub
Vec
<
TopLevelAssertion
<
'a
>
>
);
impl
TopLevelAssertions
{
impl
<
'a
>
TopLevelAssertions
<
'a
>
{
#[must_use]
pub
(
crate
)
const
fn
empty
()
->
Self
{
Self
(
vec!
[])
}
pub
(
crate
)
fn
push
(
&
mut
self
,
a
:
TopLevelAssertion
)
{
pub
(
crate
)
fn
push
(
&
mut
self
,
a
:
TopLevelAssertion
<
'a
>
)
{
self
.0
.push
(
a
);
}
}
...
...
This diff is collapsed.
Click to expand it.
rr_frontend/radium/src/specs.rs
+
26
−
20
View file @
e4a382a7
...
...
@@ -2075,26 +2075,32 @@ impl<'def> AbstractEnum<'def> {
// write the Coq inductive, if applicable
if
let
Some
(
ind
)
=
&
self
.optional_inductive_def
{
let
mut
assertions
=
coq
::
TopLevelAssertions
::
empty
();
assertions
.push
(
coq
::
TopLevelAssertion
::
Comment
(
format!
(
"auto-generated representation of {}"
,
ind
.get_name
()
)));
// TODO don't clone
assertions
.push
(
coq
::
TopLevelAssertion
::
InductiveDecl
(
ind
.clone
()));
// prove that it is inhabited
let
instance_decl
=
coq
::
InstanceDecl
::
new
(
coq
::
Type
::
Literal
(
format!
(
"Inhabited {}"
,
ind
.get_name
())),
coq
::
DefBody
::
Script
(
coq
::
ProofScript
(
vec!
[
coq
::
ProofItem
::
Literal
(
"solve_inhabited"
.to_owned
())]),
coq
::
ProofScriptTerminator
::
Qed
,
),
);
assertions
.push
(
coq
::
TopLevelAssertion
::
InstanceDecl
(
instance_decl
));
let
mut
out
=
IndentWriter
::
new
(
BASE_INDENT
,
&
mut
out
);
writeln!
(
out
)
.unwrap
();
let
name
=
ind
.get_name
();
writeln!
(
out
,
"{}"
,
coq
::
TopLevelAssertion
::
Comment
(
&
format!
(
"auto-generated representation of {}"
,
name
))
)
.unwrap
();
let
mut
code_fmt
=
IndentWriter
::
new
(
BASE_INDENT
,
&
mut
out
);
write!
(
code_fmt
,
"
\n
{assertions}
\n
"
)
.unwrap
();
writeln!
(
out
,
"{}"
,
coq
::
TopLevelAssertion
::
InductiveDecl
(
ind
))
.unwrap
();
// prove that it is inhabited
writeln!
(
out
,
"{}"
,
coq
::
TopLevelAssertion
::
InstanceDecl
(
&
coq
::
InstanceDecl
::
new
(
coq
::
Type
::
Literal
(
format!
(
"Inhabited {}"
,
name
)),
coq
::
DefBody
::
Script
(
coq
::
ProofScript
(
vec!
[
coq
::
ProofItem
::
Literal
(
"solve_inhabited"
.to_owned
())]),
coq
::
ProofScriptTerminator
::
Qed
,
),
))
)
.unwrap
();
}
// build the els term applied to generics
...
...
@@ -3467,7 +3473,7 @@ fn make_trait_instance<'def>(
is_base_spec
:
bool
,
spec_record_name
:
&
str
,
spec_record_params_name
:
&
str
,
)
->
Result
<
coq
::
TopLevelAssertions
,
fmt
::
Error
>
{
)
->
Result
<
coq
::
TopLevelAssertions
<
'def
>
,
fmt
::
Error
>
{
let
mut
assertions
=
Vec
::
new
();
// write the param record decl
...
...
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