Skip to content
Snippets Groups Projects

WIP: Pretty-print 0 as "0" for N, Z, and nat

Closed Tej Chajed requested to merge tchajed/stdpp:fix-pretty-0 into master
1 unresolved thread
2 files
+ 6
5
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 4
5
@@ -35,8 +35,8 @@ Proof.
unfold pretty_N_go_help at 1; fold pretty_N_go_help.
by destruct (decide (0 < x)%N); auto using pretty_N_go_help_irrel.
Qed.
Instance pretty_N : Pretty N := λ x, pretty_N_go x ""%string.
Lemma pretty_N_unfold x : pretty x = pretty_N_go x "".
Instance pretty_N : Pretty N := λ x, pretty_N_go x "0"%string.
Lemma pretty_N_unfold x : pretty x = pretty_N_go x "0".
Proof. done. Qed.
Instance pretty_N_inj : Inj (=@{N}) (=) pretty.
Proof.
@@ -46,7 +46,7 @@ Proof.
cut ( x y s s', pretty_N_go x s = pretty_N_go y s'
String.length s = String.length s' x = y s = s').
{ intros help x y Hp.
eapply (help x y "" ""); [by rewrite <-!pretty_N_unfold|done]. }
eapply (help x y "0" "0"); [by rewrite <-!pretty_N_unfold|done]. }
assert ( x s, ¬String.length (pretty_N_go x s) < String.length s) as help.
{ setoid_rewrite <-Nat.le_ngt.
intros x; induction (N.lt_wf_0 x) as [x _ IH]; intros s.
@@ -66,9 +66,8 @@ Proof.
Qed.
Instance pretty_Z : Pretty Z := λ x,
match x with
| Z0 => "" | Zpos x => pretty (Npos x) | Zneg x => "-" +:+ pretty (Npos x)
| Z0 => "0" | 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_inj : Inj (=@{nat}) (=) pretty.
Proof. apply _. Qed.
Loading