Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stdpp
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
Terraform modules
Monitor
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
stdpp
Commits
359bdf0f
Commit
359bdf0f
authored
4 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Fix `pretty` for `Z` and prove `injectivity` of it.
parent
1855e425
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/pretty.v
+25
-5
25 additions, 5 deletions
theories/pretty.v
with
25 additions
and
5 deletions
theories/pretty.v
+
25
−
5
View file @
359bdf0f
...
@@ -44,6 +44,7 @@ Proof.
...
@@ -44,6 +44,7 @@ Proof.
by
destruct
(
decide
(
0
<
x
)
%
N
);
auto
using
pretty_N_go_help_irrel
.
by
destruct
(
decide
(
0
<
x
)
%
N
);
auto
using
pretty_N_go_help_irrel
.
Qed
.
Qed
.
(** Helper lemma to prove [pretty_N_inj] and [pretty_Z_inj]. *)
Lemma
pretty_N_go_ne_0
x
s
:
s
≠
"0"
→
pretty_N_go
x
s
≠
"0"
.
Lemma
pretty_N_go_ne_0
x
s
:
s
≠
"0"
→
pretty_N_go
x
s
≠
"0"
.
Proof
.
Proof
.
revert
s
.
induction
(
N
.
lt_wf_0
x
)
as
[
x
_
IH
];
intros
s
?
.
revert
s
.
induction
(
N
.
lt_wf_0
x
)
as
[
x
_
IH
];
intros
s
?
.
...
@@ -57,6 +58,16 @@ Proof.
...
@@ -57,6 +58,16 @@ Proof.
apply
IH
;
[|
done
]
.
apply
IH
;
[|
done
]
.
trans
(
x
`
div
`
10
)
%
N
;
apply
N
.
div_lt
;
auto
using
N
.
div_str_pos
with
lia
.
trans
(
x
`
div
`
10
)
%
N
;
apply
N
.
div_lt
;
auto
using
N
.
div_str_pos
with
lia
.
Qed
.
Qed
.
(** Helper lemma to prove [pretty_Z_inj]. *)
Lemma
pretty_N_go_ne_dash
x
s
s'
:
s
≠
"-"
+:+
s'
→
pretty_N_go
x
s
≠
"-"
+:+
s'
.
Proof
.
revert
s
.
induction
(
N
.
lt_wf_0
x
)
as
[
x
_
IH
];
intros
s
?
.
assert
(
x
=
0
∨
0
<
x
)
%
N
as
[
->
|?]
by
lia
.
-
by
rewrite
pretty_N_go_0
.
-
rewrite
pretty_N_go_step
by
done
.
apply
IH
.
{
by
apply
N
.
div_lt
.
}
unfold
pretty_N_char
.
by
repeat
case_match
.
Qed
.
Instance
pretty_N_inj
:
Inj
(
=@
{
N
})
(
=
)
pretty
.
Instance
pretty_N_inj
:
Inj
(
=@
{
N
})
(
=
)
pretty
.
Proof
.
Proof
.
...
@@ -87,11 +98,20 @@ Proof.
...
@@ -87,11 +98,20 @@ Proof.
rewrite
(
N
.
div_mod
x
10
),
(
N
.
div_mod
y
10
)
by
done
.
lia
.
rewrite
(
N
.
div_mod
x
10
),
(
N
.
div_mod
y
10
)
by
done
.
lia
.
Qed
.
Qed
.
Instance
pretty_Z
:
Pretty
Z
:=
λ
x
,
match
x
with
|
Z0
=>
""
|
Zpos
x
=>
pretty
(
Npos
x
)
|
Zneg
x
=>
"-"
+:+
pretty
(
Npos
x
)
end
%
string
.
Instance
pretty_nat
:
Pretty
nat
:=
λ
x
,
pretty
(
N
.
of_nat
x
)
.
Instance
pretty_nat
:
Pretty
nat
:=
λ
x
,
pretty
(
N
.
of_nat
x
)
.
Instance
pretty_nat_inj
:
Inj
(
=@
{
nat
})
(
=
)
pretty
.
Instance
pretty_nat_inj
:
Inj
(
=@
{
nat
})
(
=
)
pretty
.
Proof
.
apply
_
.
Qed
.
Proof
.
apply
_
.
Qed
.
Instance
pretty_Z
:
Pretty
Z
:=
λ
x
,
match
x
with
|
Z0
=>
"0"
|
Zpos
x
=>
pretty
(
Npos
x
)
|
Zneg
x
=>
"-"
+:+
pretty
(
Npos
x
)
end
%
string
.
Instance
pretty_Z_inj
:
Inj
(
=@
{
Z
})
(
=
)
pretty
.
Proof
.
unfold
pretty
,
pretty_Z
.
intros
[|
x
|
x
]
[|
y
|
y
]
Hpretty
;
simplify_eq
/=
;
try
done
.
-
by
destruct
(
pretty_N_go_ne_0
(
N
.
pos
y
)
""
)
.
-
by
destruct
(
pretty_N_go_ne_0
(
N
.
pos
x
)
""
)
.
-
by
edestruct
(
pretty_N_go_ne_dash
(
N
.
pos
x
)
""
)
.
-
by
edestruct
(
pretty_N_go_ne_dash
(
N
.
pos
y
)
""
)
.
Qed
.
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