Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Iris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Adam
Iris
Commits
f4db0245
Commit
f4db0245
authored
8 months ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Better version of `ident_to_string`, also by
@lepigre
.
parent
9fdd6724
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iris/proofmode/string_ident.v
+17
-17
17 additions, 17 deletions
iris/proofmode/string_ident.v
with
17 additions
and
17 deletions
iris/proofmode/string_ident.v
+
17
−
17
View file @
f4db0245
From
Ltac2
Require
Ltac2
.
From
Ltac2
Require
Ltac2
.
From
Coq
Require
Import
Strings
.
String
.
From
Coq
Require
Import
Strings
.
String
.
From
Coq
Require
Import
Init
.
Byte
.
From
Coq
Require
Import
Init
.
Byte
Ascii
.
From
iris
.
prelude
Require
Import
options
.
From
iris
.
prelude
Require
Import
options
.
Import
List
.
ListNotations
.
Import
List
.
ListNotations
.
...
@@ -77,26 +77,26 @@ End StringToIdent.
...
@@ -77,26 +77,26 @@ End StringToIdent.
Module
IdentToString
.
Module
IdentToString
.
Import
Ltac2
.
Import
Ltac2
.
Ltac2
char_to_coq_byte
(
c
:
char
)
:
constr
:=
Ltac2
get_bit
(
n
:
int
)
(
i
:
int
)
:
bool
:=
let
(
ind
,
inst
)
:=
Int
.
equal
(
Int
.
land
(
Int
.
lsr
n
i
)
1
)
1
.
match
Constr
.
Unsafe
.
kind
constr
:(
byte
)
with
|
Constr
.
Unsafe
.
Ind
ind
inst
=>
(
ind
,
inst
)
Ltac2
get_bit_coq_bool
(
n
:
int
)
(
i
:
int
)
:
constr
:=
|
_
=>
Control
.
zero
(
Invalid_argument
None
)
if
get_bit
n
i
then
constr
:(
true
)
else
constr
:(
false
)
.
end
in
Ltac2
char_to_coq_ascii
(
c
:
char
)
:
constr
:=
let
c
:=
Constr
.
Unsafe
.
constructor
ind
(
Char
.
to_int
c
)
in
let
i
:=
Char
.
to_int
c
in
Constr
.
Unsafe
.
make
(
Constr
.
Unsafe
.
Constructor
c
inst
)
.
let
bs
:=
Array
.
init
8
(
get_bit_coq_bool
i
)
in
Constr
.
Unsafe
.
make
(
Constr
.
Unsafe
.
App
constr
:(
Ascii
)
bs
)
.
Ltac2
string_to_coq_string
(
s
:
string
)
:
constr
:=
Ltac2
string_to_coq_string
(
s
:
string
)
:
constr
:=
let
len
:=
String
.
length
s
in
let
len
:=
String
.
length
s
in
let
rec
to_string
acc
i
:=
let
rec
to_string
i
:=
if
Int
.
equal
i
-1
then
acc
else
if
Int
.
equal
i
len
then
constr
:(
EmptyString
)
else
let
c
:=
String
.
get
s
i
in
let
tail
:=
to_string
(
Int
.
add
i
1
)
in
let
byte
:=
char_to_coq_byte
c
in
let
head
:=
char_to_coq_ascii
(
String
.
get
s
i
)
in
let
a
:=
compute
constr
:(
Ascii
.
ascii_of_byte
$
byte
)
in
constr
:(
String
$
head
$
tail
)
to_string
constr
:(
String
$
a
$
acc
)
(
Int
.
sub
i
1
)
in
in
to_string
constr
:(
EmptyString
)
(
Int
.
sub
len
1
)
.
to_string
0
.
Ltac2
ident_to_string
(
id
:
ident
)
:
constr
:=
Ltac2
ident_to_string
(
id
:
ident
)
:
constr
:=
string_to_coq_string
(
Ident
.
to_string
id
)
.
string_to_coq_string
(
Ident
.
to_string
id
)
.
...
...
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