Library RocqOfOCaml.Basics
Require Import ssr.ssrbool.
Require Import Libraries.
Local Open Scope Z_scope.
Import ListNotations.
Set Implicit Arguments.
Polymorphic Inductive sigS (A : Type) (P : A → Type) : Type :=
| existS : ∀ (x : A), P x → sigS P.
Reserved Notation "{ x @ P }" (at level 0, x at level 99).
Reserved Notation "{ x : A @ P }" (at level 0, x at level 99).
Reserved Notation "{ ' pat : A @ P }"
(at level 0, pat strict pattern, format "{ ' pat : A @ P }").
Notation "{ x @ P }" := (sigS (fun x ⇒ P)) : type_scope.
Notation "{ x : A @ P }" := (sigS (A := A) (fun x ⇒ P)) : type_scope.
Notation "{ ' pat : A @ P }" := (sigS (A := A) (fun pat ⇒ P)) : type_scope.
Require Import Libraries.
Local Open Scope Z_scope.
Import ListNotations.
Set Implicit Arguments.
Polymorphic Inductive sigS (A : Type) (P : A → Type) : Type :=
| existS : ∀ (x : A), P x → sigS P.
Reserved Notation "{ x @ P }" (at level 0, x at level 99).
Reserved Notation "{ x : A @ P }" (at level 0, x at level 99).
Reserved Notation "{ ' pat : A @ P }"
(at level 0, pat strict pattern, format "{ ' pat : A @ P }").
Notation "{ x @ P }" := (sigS (fun x ⇒ P)) : type_scope.
Notation "{ x : A @ P }" := (sigS (A := A) (fun x ⇒ P)) : type_scope.
Notation "{ ' pat : A @ P }" := (sigS (A := A) (fun pat ⇒ P)) : type_scope.
Conversion from a module to a first-class module.
Polymorphic Definition pack {A : Type} {P : A → Type}
(M : {x : A & P x}) : {x : A @ P x} :=
let 'existT _ _ M := M in
existS _ _ M.
Notation "(| record |)" := (projT2 record).
Module Primitive.
Set Primitive Projections.
Record prod {A B : Type} : Type := pair {
fst : A;
snd : B;
}.
Arguments prod : clear implicits.
Unset Primitive Projections.
End Primitive.
Notation "[ X ** Y ** .. ** Z ]" :=
(Primitive.prod .. (Primitive.prod X Y) .. Z) : type_scope.
Notation "[ x , y , .. , z ]" :=
(Primitive.pair .. (Primitive.pair x y) .. z).
Class OrderDec {A R} `(StrictOrder A R) := {
compare : A → A → comparison;
compare_is_sound : ∀ x y,
CompareSpec (x = y) (R x y) (R y x) (compare x y) }.
Definition array (A : Set) : Set := list A.
(M : {x : A & P x}) : {x : A @ P x} :=
let 'existT _ _ M := M in
existS _ _ M.
Notation "(| record |)" := (projT2 record).
Module Primitive.
Set Primitive Projections.
Record prod {A B : Type} : Type := pair {
fst : A;
snd : B;
}.
Arguments prod : clear implicits.
Unset Primitive Projections.
End Primitive.
Notation "[ X ** Y ** .. ** Z ]" :=
(Primitive.prod .. (Primitive.prod X Y) .. Z) : type_scope.
Notation "[ x , y , .. , z ]" :=
(Primitive.pair .. (Primitive.pair x y) .. z).
Class OrderDec {A R} `(StrictOrder A R) := {
compare : A → A → comparison;
compare_is_sound : ∀ x y,
CompareSpec (x = y) (R x y) (R y x) (compare x y) }.
Definition array (A : Set) : Set := list A.
A uniquely inhabited typeclass used only as Rocq's syntactic structural
parameter when translated OCaml recursion has no inductive argument.
Calls do not expose it: typeclass inference always supplies the global
instance.
Inductive GeneralRecursionGuard : Set :=
| general_recursion_guard : GeneralRecursionGuard.
Existing Class GeneralRecursionGuard.
Global Instance default_general_recursion_guard : GeneralRecursionGuard :=
general_recursion_guard.
| general_recursion_guard : GeneralRecursionGuard.
Existing Class GeneralRecursionGuard.
Global Instance default_general_recursion_guard : GeneralRecursionGuard :=
general_recursion_guard.
A name-indexed ranking function used by generated well-founded
definitions. Program records each recursive call's decrease as a
separate proof obligation; the function alone makes no termination claim.
Including the lexical definition name and its captured environment lets
unrelated local recursive definitions use independent rankings.
A total, step-indexed approximation of an OCaml recursive-module knot.
The generated definition receives seed through an Unreachable
requirement, making the approximation boundary explicit. Projects that
execute recursive modules must replace the seed and justify a sufficient
unrolling bound; there is no sound general fixed-point operator on Type.
Partial module interfaces may themselves live above Set.
Definition recursive_module_default_fuel : nat := 1024%nat.
Polymorphic Fixpoint recursive_module_unroll {A : Type} (fuel : nat) (seed : A)
(f : A → A) : A :=
match fuel with
| O ⇒ seed
| S remaining ⇒ f (recursive_module_unroll remaining seed f)
end.
Class Unreachable (T : Type) := {
unreachable : T;
}.
Class Unimplemented (T : Type) := {
unimplemented : T;
}.
Polymorphic Fixpoint recursive_module_unroll {A : Type} (fuel : nat) (seed : A)
(f : A → A) : A :=
match fuel with
| O ⇒ seed
| S remaining ⇒ f (recursive_module_unroll remaining seed f)
end.
Class Unreachable (T : Type) := {
unreachable : T;
}.
Class Unimplemented (T : Type) := {
unimplemented : T;
}.
A proof dependency, never an arbitrary executable value. Concrete module
applications must supply a proof of P; no default instance is provided.
Class Law (P : Prop) : Prop := {
law : P;
}.
Arguments unreachable {T} {_}.
Arguments unimplemented {T} {_}.
law : P;
}.
Arguments unreachable {T} {_}.
Arguments unimplemented {T} {_}.
Select the value carried by an explicit Unreachable instance. Generated
recursive-module code uses this helper to make its finite-unrolling seed a
visible functor dependency instead of relying on global type-class search.
Specialize a family carried by an explicit assumption class.
Definition specialize_unreachable {A : Type} {T : A → Type}
(instance : Unreachable (∀ x, T x)) (x : A) : Unreachable (T x) :=
{| unreachable := @unreachable (∀ x, T x) instance x |}.
Definition specialize_unimplemented {A : Type} {T : A → Type}
(instance : Unimplemented (∀ x, T x)) (x : A) : Unimplemented (T x) :=
{| unimplemented := @unimplemented (∀ x, T x) instance x |}.
Definition specialize_law {A : Type} {P : A → Prop}
(instance : Law (∀ x, P x)) (x : A) : Law (P x) :=
{| law := @law (∀ x, P x) instance x |}.
(instance : Unreachable (∀ x, T x)) (x : A) : Unreachable (T x) :=
{| unreachable := @unreachable (∀ x, T x) instance x |}.
Definition specialize_unimplemented {A : Type} {T : A → Type}
(instance : Unimplemented (∀ x, T x)) (x : A) : Unimplemented (T x) :=
{| unimplemented := @unimplemented (∀ x, T x) instance x |}.
Definition specialize_law {A : Type} {P : A → Prop}
(instance : Law (∀ x, P x)) (x : A) : Law (P x) :=
{| law := @law (∀ x, P x) instance x |}.
Keep a section variable as an explicit parameter of a generated
definition even when Rocq can erase every computational use of it.
Definition with_context {Context : Type}
(_ : Context) (Result : Set) : Set :=
Result.
Inductive extensible_type : Type :=
| Build_extensible : string → ∀ (A : Set), A → extensible_type.
Arguments Build_extensible : clear implicits.
(_ : Context) (Result : Set) : Set :=
Result.
Inductive extensible_type : Type :=
| Build_extensible : string → ∀ (A : Set), A → extensible_type.
Arguments Build_extensible : clear implicits.
Polymorphic variants.
Module Variant.
Inductive t : Type :=
| Build : string → ∀ (A : Set), A → t.
Arguments Build : clear implicits.
End Variant.
Definition int := Z.
Definition float := Z.
Definition int32 := Z.
Definition int64 := Z.
Definition nativeint := Z.
Definition bytes := string.
Definition try {A : Set} (x : A) : A := x.
Definition try_with {A : Set} (e : unit → A) (_with : extensible_type → A)
: A :=
e tt.
Module Unit.
Definition lt (x y : unit) : Prop := False.
Global Instance strict_order : StrictOrder lt.
refine {|
StrictOrder_Irreflexive := _;
StrictOrder_Transitive := _ |}.
- intro x.
unfold complement, lt.
trivial.
- intros x y z Rxy Ryz.
exact Rxy.
Qed.
Global Instance order_dec : OrderDec strict_order.
refine {|
compare := fun x y ⇒ Eq;
compare_is_sound := fun x y ⇒ CompEq _ _ _ |}.
abstract (now destruct x; destruct y).
Defined.
End Unit.
Module Bool.
Inductive lt : bool → bool → Prop :=
| lt_intro : lt false true.
Global Instance strict_order : StrictOrder lt.
refine {|
StrictOrder_Irreflexive := _;
StrictOrder_Transitive := _ |}.
- intros x Hxx.
inversion Hxx.
- intros x y z Hxy Hyz.
destruct Hxy; destruct Hyz.
constructor.
Qed.
Global Instance order_dec : OrderDec strict_order.
refine {|
compare := fun x y ⇒
match (x, y) with
| (false, true) ⇒ Lt
| (false, false) | (true, true) ⇒ Eq
| (true, false) ⇒ Gt
end;
compare_is_sound := fun x y ⇒ _ |}.
abstract (destruct x; destruct y;
try apply CompLt; try apply CompEq; try apply CompGt;
constructor).
Defined.
End Bool.
Module Z.
Global Instance eq_dec : EqDec (eq_setoid Z) := Z.eq_dec.
Global Instance order_dec : OrderDec Z.lt_strorder := {|
compare := Z.compare;
compare_is_sound := Z.compare_spec |}.
End Z.
Inductive t : Type :=
| Build : string → ∀ (A : Set), A → t.
Arguments Build : clear implicits.
End Variant.
Definition int := Z.
Definition float := Z.
Definition int32 := Z.
Definition int64 := Z.
Definition nativeint := Z.
Definition bytes := string.
Definition try {A : Set} (x : A) : A := x.
Definition try_with {A : Set} (e : unit → A) (_with : extensible_type → A)
: A :=
e tt.
Module Unit.
Definition lt (x y : unit) : Prop := False.
Global Instance strict_order : StrictOrder lt.
refine {|
StrictOrder_Irreflexive := _;
StrictOrder_Transitive := _ |}.
- intro x.
unfold complement, lt.
trivial.
- intros x y z Rxy Ryz.
exact Rxy.
Qed.
Global Instance order_dec : OrderDec strict_order.
refine {|
compare := fun x y ⇒ Eq;
compare_is_sound := fun x y ⇒ CompEq _ _ _ |}.
abstract (now destruct x; destruct y).
Defined.
End Unit.
Module Bool.
Inductive lt : bool → bool → Prop :=
| lt_intro : lt false true.
Global Instance strict_order : StrictOrder lt.
refine {|
StrictOrder_Irreflexive := _;
StrictOrder_Transitive := _ |}.
- intros x Hxx.
inversion Hxx.
- intros x y z Hxy Hyz.
destruct Hxy; destruct Hyz.
constructor.
Qed.
Global Instance order_dec : OrderDec strict_order.
refine {|
compare := fun x y ⇒
match (x, y) with
| (false, true) ⇒ Lt
| (false, false) | (true, true) ⇒ Eq
| (true, false) ⇒ Gt
end;
compare_is_sound := fun x y ⇒ _ |}.
abstract (destruct x; destruct y;
try apply CompLt; try apply CompEq; try apply CompGt;
constructor).
Defined.
End Bool.
Module Z.
Global Instance eq_dec : EqDec (eq_setoid Z) := Z.eq_dec.
Global Instance order_dec : OrderDec Z.lt_strorder := {|
compare := Z.compare;
compare_is_sound := Z.compare_spec |}.
End Z.
OCaml functions are converted to their Rocq's counter parts when it is
possible.
OCaml exception-raising operations are partial in the pure Gallina
embedding. Each translated use must supply a type-specific
Unreachable instance and prove separately that execution cannot use
its value.
Definition failwith {a : Set} `{Unreachable a} (_ : string) : a :=
unreachable.
Definition invalid_arg {a : Set} `{Unreachable a} (_ : string) : a :=
unreachable.
Definition raise {a : Set} `{Unreachable a} (_ : extensible_type) : a :=
unreachable.
unreachable.
Definition invalid_arg {a : Set} `{Unreachable a} (_ : string) : a :=
unreachable.
Definition raise {a : Set} `{Unreachable a} (_ : extensible_type) : a :=
unreachable.
OCaml implements these operations by inspecting runtime
representations. Parametric Gallina code cannot reproduce that
behavior for an arbitrary Set, so translations that use the
polymorphic primitives expose them as an explicit trusted boundary.
Parameter polymorphic_compare : ∀ {a : Set}, a → a → int.
Parameter polymorphic_equal : ∀ {a : Set}, a → a → bool.
Definition polymorphic_not_equal {a : Set} (x y : a) : bool :=
negb (polymorphic_equal x y).
Parameter physical_equal : ∀ {a : Set}, a → a → bool.
Module Atomic.
Definition make {a : Set} (value : a) : a := value.
Definition exchange {a : Set} (current replacement : a) : a :=
let _ := replacement in
current.
End Atomic.
Definition ref_value {a : Set} (value : a) : a := value.
Definition op_exclamation {a : Set} (cell : a) : a := cell.
Definition op_coloneq {a : Set} (_cell replacement : a) : unit :=
let _ := replacement in
tt.
Parameter polymorphic_equal : ∀ {a : Set}, a → a → bool.
Definition polymorphic_not_equal {a : Set} (x y : a) : bool :=
negb (polymorphic_equal x y).
Parameter physical_equal : ∀ {a : Set}, a → a → bool.
Module Atomic.
Definition make {a : Set} (value : a) : a := value.
Definition exchange {a : Set} (current replacement : a) : a :=
let _ := replacement in
current.
End Atomic.
Definition ref_value {a : Set} (value : a) : a := value.
Definition op_exclamation {a : Set} (cell : a) : a := cell.
Definition op_coloneq {a : Set} (_cell replacement : a) : unit :=
let _ := replacement in
tt.
Definition lt {A : Set} (x y : A) : bool :=
Z.ltb (polymorphic_compare x y) 0.
Definition gt {A : Set} (x y : A) : bool :=
Z.gtb (polymorphic_compare x y) 0.
Definition le {A : Set} (x y : A) : bool :=
Z.leb (polymorphic_compare x y) 0.
Definition ge {A : Set} (x y : A) : bool :=
Z.geb (polymorphic_compare x y) 0.
Definition min {A : Set} (x y : A) : A :=
if le x y then x else y.
Definition max {A : Set} (x y : A) : A :=
if ge x y then x else y.
Definition compare {A : Set} (x y : A) : Z :=
polymorphic_compare x y.
Z.ltb (polymorphic_compare x y) 0.
Definition gt {A : Set} (x y : A) : bool :=
Z.gtb (polymorphic_compare x y) 0.
Definition le {A : Set} (x y : A) : bool :=
Z.leb (polymorphic_compare x y) 0.
Definition ge {A : Set} (x y : A) : bool :=
Z.geb (polymorphic_compare x y) 0.
Definition min {A : Set} (x y : A) : A :=
if le x y then x else y.
Definition max {A : Set} (x y : A) : A :=
if ge x y then x else y.
Definition compare {A : Set} (x y : A) : Z :=
polymorphic_compare x y.
Definition string_of_bool (b : bool) : string :=
if b then
"true" % string
else
"false" % string.
Definition bool_of_string (s : string) : bool :=
false.
Definition string_of_int (n : Z) : string :=
"0" % string.
Definition int_of_string (s : string) : Z :=
0.
if b then
"true" % string
else
"false" % string.
Definition bool_of_string (s : string) : bool :=
false.
Definition string_of_int (n : Z) : string :=
"0" % string.
Definition int_of_string (s : string) : Z :=
0.
Computational equality instances used when translating OCaml's
polymorphic equality at types whose Gallina representation supports it.
Module Equality.
Global Instance string_eq_dec : EqDec (eq_setoid string) :=
String.string_dec.
Global Instance list_eq_dec {A : Type}
(A_eq_dec : EqDec (eq_setoid A))
: EqDec (eq_setoid (list A)) :=
List.list_eq_dec (@equiv_dec A (eq_setoid A) A_eq_dec).
Global Instance option_eq_dec {A : Type}
(A_eq_dec : EqDec (eq_setoid A))
: EqDec (eq_setoid (option A)).
Proof.
intros x y.
change ({x = y} + {x ≠ y}).
decide equality.
apply (@equiv_dec A (eq_setoid A) A_eq_dec).
Defined.
End Equality.
Module Char.
Global Instance eq_dec : EqDec (eq_setoid ascii) := ascii_dec.
Module Lt.
Definition t (c1 c2 : ascii) : Prop :=
N.lt (N_of_ascii c1) (N_of_ascii c2).
Lemma irreflexivity (c : ascii) : ¬ t c c.
apply N.lt_irrefl.
Qed.
Lemma transitivity (c1 c2 c3 : ascii) : t c1 c2 → t c2 c3 → t c1 c3.
apply N.lt_trans.
Qed.
Lemma N_of_ascii_inj (c1 c2 : ascii) : N_of_ascii c1 = N_of_ascii c2 → c1 = c2.
intro H.
rewrite <- (ascii_N_embedding c1).
rewrite <- (ascii_N_embedding c2).
rewrite H.
reflexivity.
Qed.
End Lt.
Global Instance strict_order : StrictOrder Lt.t :=
{|
StrictOrder_Irreflexive := Lt.irreflexivity;
StrictOrder_Transitive := Lt.transitivity;
|}.
Global Instance order_dec : OrderDec strict_order.
refine {|
compare := fun c1 c2 ⇒ (N_of_ascii c1 ?= N_of_ascii c2) % N;
compare_is_sound := fun c1 c2 ⇒ _;
|}.
destruct (N.compare_spec (N_of_ascii c1) (N_of_ascii c2)) as [Heq | Hlt | Hgt];
[apply CompEq | apply CompLt | apply CompGt].
- now apply Lt.N_of_ascii_inj.
- exact Hlt.
- exact Hgt.
Defined.
End Char.
Module Seq.
Reserved Notation "'t".
Inductive node (A : Set) : Set :=
| Nil : node A
| Cons : A → 't A → node A
where "'t" := (fun (T : Set) ⇒ unit → node T).
Definition t := 't.
Arguments Nil {_}.
Arguments Cons {_}.
End Seq.
Module String.
Definition length (s : string) : Z :=
Z.of_nat (String.length s).
Definition get (s : string) (n : Z) : ascii :=
match String.get (Z.to_nat n) s with
| None ⇒ "?" % char
| Some c ⇒ c
end.
Fixpoint _make (n : nat) (c : ascii) : string :=
match n with
| O ⇒ EmptyString
| S n ⇒ String c (_make n c)
end.
Fixpoint concat (sep : string) (sl : list string) : string :=
match sl with
| [] ⇒ ""
| [s] ⇒ s
| s :: sl ⇒ String.append (String.append s sep) (concat sep sl)
end.
Definition make (n : Z) (c : ascii) : string :=
_make (Z.to_nat n) c.
Definition sub (s : string) (start : Z) (length : Z) : string :=
s.
Definition escaped (s : string) : string :=
s.
Module Lt.
Inductive t : string → string → Prop :=
| EmptyString : ∀ c s, t EmptyString (String c s)
| StringStringLt : ∀ c1 s1 c2 s2,
N.lt (N_of_ascii c1) (N_of_ascii c2) → t (String c1 s1) (String c2 s2)
| StringStringEq : ∀ c1 s1 c2 s2,
c1 = c2 → t s1 s2 → t (String c1 s1) (String c2 s2).
Fixpoint irreflexivity (s : string) (H : t s s) : False.
inversion_clear H.
- apply (Char.Lt.irreflexivity H0).
- apply (irreflexivity _ H1).
Qed.
Fixpoint transitivity (s1 s2 s3 : string) (H12 : t s1 s2) (H23 : t s2 s3) : t s1 s3.
inversion H12; inversion H23; try apply EmptyString; try congruence.
- apply StringStringLt.
apply N.lt_trans with (m := N_of_ascii c2); congruence.
- apply StringStringLt; congruence.
- apply StringStringLt; congruence.
- apply StringStringEq; try congruence.
replace s4 with s5 in × by congruence.
now apply transitivity with (s2 := s5).
Qed.
End Lt.
Fixpoint ltb (s1 s2 : string) : bool :=
match s1, s2 with
| EmptyString, EmptyString ⇒ false
| EmptyString, String _ _ ⇒ true
| String _ _, EmptyString ⇒ false
| String c1 s1', String c2 s2' ⇒
let n1 := N_of_ascii c1 in
let n2 := N_of_ascii c2 in
(N.ltb n1 n2 || (N.eqb n1 n2 && ltb s1' s2')) % bool
end.
Fixpoint ltb_spec (s1 s2 : string) : Bool.reflect (Lt.t s1 s2) (ltb s1 s2).
destruct s1 as [| c1 s1]; destruct s2 as [| c2 s2]; simpl.
- apply Bool.ReflectF.
intro; now apply Lt.irreflexivity with (s := "" % string).
- apply Bool.ReflectT.
apply Lt.EmptyString.
- apply Bool.ReflectF.
intro H; inversion H.
- case_eq ((N_of_ascii c1 <? N_of_ascii c2)%N); intro H_lt; simpl.
+ apply Bool.ReflectT.
apply Lt.StringStringLt.
now apply N.ltb_lt.
+ case_eq ((N_of_ascii c1 =? N_of_ascii c2)%N); intro H_eq; simpl.
× destruct (ltb_spec s1 s2); constructor.
-- apply Lt.StringStringEq; trivial.
apply Char.Lt.N_of_ascii_inj.
now apply N.eqb_eq.
-- intro H; inversion H; try tauto.
assert ((N_of_ascii c1 <? N_of_ascii c2)%N = true) by
now apply N.ltb_lt.
congruence.
× apply Bool.ReflectF.
intro H; inversion H.
-- assert ((N_of_ascii c1 <? N_of_ascii c2)%N = true) by
now apply N.ltb_lt.
congruence.
-- assert ((N_of_ascii c1 =? N_of_ascii c2)%N = true) by
(apply N.eqb_eq; congruence).
congruence.
Qed.
Fixpoint ltb_or_eqb_or_gtb
(s1 s2 : string)
(H_nltb : ltb s1 s2 = false)
(H_neqb : String.eqb s1 s2 = false)
: ltb s2 s1 = true.
destruct s1 as [| c1 s1]; destruct s2 as [| c2 s2]; simpl in *; try congruence.
destruct (Bool.orb_false_elim _ _ H_nltb) as [H_c1c2 H].
case_eq ((N_of_ascii c1 ?= N_of_ascii c2)%N); intro H_comp_c1c2.
- assert (H_eq_c1c2 : N_of_ascii c1 = N_of_ascii c2) by
now apply N.compare_eq_iff.
replace ((N_of_ascii c2 =? N_of_ascii c1)%N) with true by (
symmetry;
apply N.eqb_eq;
congruence
).
rewrite ltb_or_eqb_or_gtb.
+ apply Bool.orb_true_r.
+ destruct (proj1 (Bool.andb_false_iff _ _) H); trivial.
assert (H_eq_c1c2_bis := proj2 (N.eqb_eq _ _) H_eq_c1c2).
congruence.
+ assert (H_eqb_c1c2 : (c1 =? c2)%char = true) by (
apply Ascii.eqb_eq;
now apply Char.Lt.N_of_ascii_inj
).
now rewrite H_eqb_c1c2 in H_neqb.
- assert ((N_of_ascii c1 <? N_of_ascii c2)%N = true) by (
apply N.ltb_lt;
now apply N.compare_lt_iff
).
congruence.
- assert (H_gt_c1c2 : (N_of_ascii c2 < N_of_ascii c1) % N) by
now apply N.compare_gt_iff.
now rewrite (proj2 (N.ltb_lt _ _) H_gt_c1c2).
Qed.
Global Instance strict_order : StrictOrder Lt.t := {|
StrictOrder_Irreflexive := Lt.irreflexivity;
StrictOrder_Transitive := Lt.transitivity;
|}.
Global Instance order_dec : OrderDec strict_order.
refine {|
compare := fun s1 s2 ⇒
if String.eqb s1 s2 then
Eq
else if ltb s1 s2 then
Lt
else
Gt;
compare_is_sound := fun s1 s2 ⇒ _;
|}.
case_eq (String.eqb s1 s2); intro H_eq.
- apply CompEq.
now apply String.eqb_eq.
- case_eq (ltb s1 s2); intro H_lt.
+ apply CompLt.
apply (ltb_spec _ _ H_lt).
+ apply CompGt.
apply (ltb_spec _ _ (ltb_or_eqb_or_gtb _ _ H_lt H_eq)).
Defined.
End String.
Module CamlinternalFormatBasics.
Inductive padty : Type :=
| Left : padty
| Right : padty
| Zeros : padty.
Inductive int_conv : Type :=
| Int_d : int_conv
| Int_pd : int_conv
| Int_sd : int_conv
| Int_i : int_conv
| Int_pi : int_conv
| Int_si : int_conv
| Int_x : int_conv
| Int_Cx : int_conv
| Int_X : int_conv
| Int_CX : int_conv
| Int_o : int_conv
| Int_Co : int_conv
| Int_u : int_conv.
Inductive float_conv : Type :=
| Float_f : float_conv
| Float_pf : float_conv
| Float_sf : float_conv
| Float_e : float_conv
| Float_pe : float_conv
| Float_se : float_conv
| Float_E : float_conv
| Float_pE : float_conv
| Float_sE : float_conv
| Float_g : float_conv
| Float_pg : float_conv
| Float_sg : float_conv
| Float_G : float_conv
| Float_pG : float_conv
| Float_sG : float_conv
| Float_F : float_conv
| Float_h : float_conv
| Float_ph : float_conv
| Float_sh : float_conv
| Float_H : float_conv
| Float_pH : float_conv
| Float_sH : float_conv.
Definition char_set : Type := string.
Inductive counter : Type :=
| Line_counter : counter
| Char_counter : counter
| Token_counter : counter.
Reserved Notation "'padding".
Inductive padding_gadt : Type :=
| No_padding_gadt : padding_gadt
| Lit_padding_gadt : padty → int → padding_gadt
| Arg_padding_gadt : padty → padding_gadt
where "'padding" := (fun (_ _ : Type) ⇒ padding_gadt).
Definition padding := 'padding.
Definition No_padding : padding_gadt := No_padding_gadt.
Definition Lit_padding : padty → int → padding_gadt := Lit_padding_gadt.
Definition Arg_padding {a : Type} : padty → padding (int → a) a :=
Arg_padding_gadt.
Definition pad_option : Type := option int.
Reserved Notation "'precision".
Inductive precision_gadt : Type :=
| No_precision_gadt : precision_gadt
| Lit_precision_gadt : int → precision_gadt
| Arg_precision_gadt : precision_gadt
where "'precision" := (fun (_ _ : Type) ⇒ precision_gadt).
Definition precision := 'precision.
Definition No_precision : precision_gadt := No_precision_gadt.
Definition Lit_precision {a : Type} : int → precision a a := Lit_precision_gadt.
Definition Arg_precision {a : Type} : precision (int → a) a :=
Arg_precision_gadt.
Definition prec_option : Type := option int.
Reserved Notation "'custom_arity".
Inductive custom_arity_gadt : Type :=
| Custom_zero_gadt : custom_arity_gadt
| Custom_succ_gadt : custom_arity_gadt → custom_arity_gadt
where "'custom_arity" := (fun (_ _ _ : Type) ⇒ custom_arity_gadt).
Definition custom_arity := 'custom_arity.
Definition Custom_zero {a : Type} : custom_arity a string a := Custom_zero_gadt.
Definition Custom_succ {a b c x : Type} :
custom_arity a b c → custom_arity a (x → b) (x → c) := Custom_succ_gadt.
Inductive block_type : Type :=
| Pp_hbox : block_type
| Pp_vbox : block_type
| Pp_hvbox : block_type
| Pp_hovbox : block_type
| Pp_box : block_type
| Pp_fits : block_type.
Inductive formatting_lit : Type :=
| Close_box : formatting_lit
| Close_tag : formatting_lit
| Break : string → int → int → formatting_lit
| FFlush : formatting_lit
| Force_newline : formatting_lit
| Flush_newline : formatting_lit
| Magic_size : string → int → formatting_lit
| Escaped_at : formatting_lit
| Escaped_percent : formatting_lit
| Scan_indic : ascii → formatting_lit.
Reserved Notation "'formatting_gen".
Reserved Notation "'fmtty_rel".
Reserved Notation "'fmtty".
Reserved Notation "'fmt".
Reserved Notation "'ignored".
Reserved Notation "'format6".
Inductive formatting_gen_gadt : Type :=
| Open_tag_gadt : ∀ {a b c d e f : Type},
'format6 a b c d e f → formatting_gen_gadt
| Open_box_gadt : ∀ {a b c d e f : Type},
'format6 a b c d e f → formatting_gen_gadt
with fmtty_rel_gadt : Type :=
| Char_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| String_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Int_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Int32_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Nativeint_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Int64_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Float_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Bool_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Format_arg_ty_gadt : ∀ {g h i j k l : Type},
'fmtty g h i j k l → fmtty_rel_gadt → fmtty_rel_gadt
| Format_subst_ty_gadt :
fmtty_rel_gadt → fmtty_rel_gadt → fmtty_rel_gadt → fmtty_rel_gadt
| Alpha_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Theta_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Any_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Reader_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Ignored_reader_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| End_of_fmtty_gadt : fmtty_rel_gadt
with fmt_gadt : Type :=
| Char_gadt : fmt_gadt → fmt_gadt
| Caml_char_gadt : fmt_gadt → fmt_gadt
| String_gadt : ∀ {a x : Type},
padding x (string → a) → fmt_gadt → fmt_gadt
| Caml_string_gadt : ∀ {a x : Type},
padding x (string → a) → fmt_gadt → fmt_gadt
| Int_gadt : ∀ {a x y : Type},
int_conv → padding x y → precision y (int → a) → fmt_gadt → fmt_gadt
| Int32_gadt : ∀ {a x y : Type},
int_conv → padding x y → precision y (int32 → a) → fmt_gadt → fmt_gadt
| Nativeint_gadt : ∀ {a x y : Type},
int_conv → padding x y → precision y (nativeint → a) → fmt_gadt →
fmt_gadt
| Int64_gadt : ∀ {a x y : Type},
int_conv → padding x y → precision y (int64 → a) → fmt_gadt → fmt_gadt
| Float_gadt : ∀ {a x y : Type},
float_conv → padding x y → precision y (float → a) → fmt_gadt → fmt_gadt
| Bool_gadt : ∀ {a x : Type}, padding x (bool → a) → fmt_gadt → fmt_gadt
| Flush_gadt : fmt_gadt → fmt_gadt
| String_literal_gadt : string → fmt_gadt → fmt_gadt
| Char_literal_gadt : ascii → fmt_gadt → fmt_gadt
| Format_arg_gadt : ∀ {g h i j k l : Type},
pad_option → 'fmtty g h i j k l → fmt_gadt → fmt_gadt
| Format_subst_gadt : ∀ {a b c d g g2 h i j j2 k l : Type},
pad_option → 'fmtty_rel g h i j k l g2 b c j2 d a → fmt_gadt → fmt_gadt
| Alpha_gadt : fmt_gadt → fmt_gadt
| Theta_gadt : fmt_gadt → fmt_gadt
| Formatting_lit_gadt : formatting_lit → fmt_gadt → fmt_gadt
| Formatting_gen_gadt : ∀ {a1 b c d1 e1 f1 : Type},
'formatting_gen a1 b c d1 e1 f1 → fmt_gadt → fmt_gadt
| Reader_gadt : fmt_gadt → fmt_gadt
| Scan_char_set_gadt : pad_option → char_set → fmt_gadt → fmt_gadt
| Scan_get_counter_gadt : counter → fmt_gadt → fmt_gadt
| Scan_next_char_gadt : fmt_gadt → fmt_gadt
| Ignored_param_gadt : ∀ {a b c d x y : Type},
'ignored a b c d y x → fmt_gadt → fmt_gadt
| Custom_gadt : ∀ {a x y : Type},
custom_arity a x y → (unit → x) → fmt_gadt → fmt_gadt
| End_of_format_gadt : fmt_gadt
with ignored_gadt : Type :=
| Ignored_char_gadt : ignored_gadt
| Ignored_caml_char_gadt : ignored_gadt
| Ignored_string_gadt : pad_option → ignored_gadt
| Ignored_caml_string_gadt : pad_option → ignored_gadt
| Ignored_int_gadt : int_conv → pad_option → ignored_gadt
| Ignored_int32_gadt : int_conv → pad_option → ignored_gadt
| Ignored_nativeint_gadt : int_conv → pad_option → ignored_gadt
| Ignored_int64_gadt : int_conv → pad_option → ignored_gadt
| Ignored_float_gadt : pad_option → prec_option → ignored_gadt
| Ignored_bool_gadt : pad_option → ignored_gadt
| Ignored_format_arg_gadt : ∀ {g h i j k l : Type},
pad_option → 'fmtty g h i j k l → ignored_gadt
| Ignored_format_subst_gadt : ∀ {a b c d e f : Type},
pad_option → 'fmtty a b c d e f → ignored_gadt
| Ignored_reader_gadt : ignored_gadt
| Ignored_scan_char_set_gadt : pad_option → char_set → ignored_gadt
| Ignored_scan_get_counter_gadt : counter → ignored_gadt
| Ignored_scan_next_char_gadt : ignored_gadt
with format6_gadt : Type :=
| Format_gadt : ∀ {a b c d e f : Type},
'fmt a b c d e f → string → format6_gadt
where "'formatting_gen" := (fun (_ _ _ _ _ _ : Type) ⇒ formatting_gen_gadt)
and "'fmtty_rel" := (fun (_ _ _ _ _ _ _ _ _ _ _ _ : Type) ⇒ fmtty_rel_gadt)
and "'fmtty" := (fun (t_a t_b t_c t_d t_e t_f : Type) ⇒
'fmtty_rel t_a t_b t_c t_d t_e t_f t_a t_b t_c t_d t_e t_f)
and "'fmt" := (fun (_ _ _ _ _ _ : Type) ⇒ fmt_gadt)
and "'ignored" := (fun (_ _ _ _ _ _ : Type) ⇒ ignored_gadt)
and "'format6" := (fun (_ _ _ _ _ _ : Type) ⇒ format6_gadt).
Definition formatting_gen := 'formatting_gen.
Definition fmtty_rel := 'fmtty_rel.
Definition fmtty := 'fmtty.
Definition fmt := 'fmt.
Definition ignored := 'ignored.
Definition format6 := 'format6.
Definition Open_tag {a b c d e f : Type} :
format6 a b c d e f → formatting_gen a b c d e f := Open_tag_gadt (a := a)
(b := b) (c := c) (d := d) (e := e) (f := f).
Definition Open_box {a b c d e f : Type} :
format6 a b c d e f → formatting_gen a b c d e f := Open_box_gadt (a := a)
(b := b) (c := c) (d := d) (e := e) (f := f).
Definition Char_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (ascii → a1) b1 c1 d1 e1 f1 (ascii → a2) b2 c2 d2 e2 f2 :=
Char_ty_gadt.
Definition String_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (string → a1) b1 c1 d1 e1 f1 (string → a2) b2 c2 d2 e2 f2 :=
String_ty_gadt.
Definition Int_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (int → a1) b1 c1 d1 e1 f1 (int → a2) b2 c2 d2 e2 f2 :=
Int_ty_gadt.
Definition Int32_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (int32 → a1) b1 c1 d1 e1 f1 (int32 → a2) b2 c2 d2 e2 f2 :=
Int32_ty_gadt.
Definition Nativeint_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (nativeint → a1) b1 c1 d1 e1 f1 (nativeint → a2) b2 c2 d2 e2 f2 :=
Nativeint_ty_gadt.
Definition Int64_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (int64 → a1) b1 c1 d1 e1 f1 (int64 → a2) b2 c2 d2 e2 f2 :=
Int64_ty_gadt.
Definition Float_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (float → a1) b1 c1 d1 e1 f1 (float → a2) b2 c2 d2 e2 f2 :=
Float_ty_gadt.
Definition Bool_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (bool → a1) b1 c1 d1 e1 f1 (bool → a2) b2 c2 d2 e2 f2 :=
Bool_ty_gadt.
Definition Format_arg_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 g h i j k l : Type}
:
fmtty g h i j k l → fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (format6 g h i j k l → a1) b1 c1 d1 e1 f1
(format6 g h i j k l → a2) b2 c2 d2 e2 f2 := Format_arg_ty_gadt (g := g)
(h := h) (i := i) (j := j) (k := k) (l := l).
Definition Format_subst_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 g g1 g2 h i j j1
j2 k l : Type} :
fmtty_rel g h i j k l g1 b1 c1 j1 d1 a1 →
fmtty_rel g h i j k l g2 b2 c2 j2 d2 a2 →
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (format6 g h i j k l → g1) b1 c1 j1 e1 f1
(format6 g h i j k l → g2) b2 c2 j2 e2 f2 := Format_subst_ty_gadt.
Definition Alpha_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 x : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel ((b1 → x → c1) → x → a1) b1 c1 d1 e1 f1
((b2 → x → c2) → x → a2) b2 c2 d2 e2 f2 := Alpha_ty_gadt.
Definition Theta_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel ((b1 → c1) → a1) b1 c1 d1 e1 f1 ((b2 → c2) → a2) b2 c2 d2 e2 f2
:= Theta_ty_gadt.
Definition Any_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 x : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (x → a1) b1 c1 d1 e1 f1 (x → a2) b2 c2 d2 e2 f2 := Any_ty_gadt.
Definition Reader_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 x : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (x → a1) b1 c1 ((b1 → x) → d1) e1 f1 (x → a2) b2 c2
((b2 → x) → d2) e2 f2 := Reader_ty_gadt.
Definition Ignored_reader_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 x : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel a1 b1 c1 ((b1 → x) → d1) e1 f1 a2 b2 c2 ((b2 → x) → d2) e2 f2 :=
Ignored_reader_ty_gadt.
Definition End_of_fmtty {b1 b2 c1 c2 d1 d2 f1 f2 : Type} :
fmtty_rel f1 b1 c1 d1 d1 f1 f2 b2 c2 d2 d2 f2 := End_of_fmtty_gadt.
Definition Char {a b c d e f : Type} :
fmt a b c d e f → fmt (ascii → a) b c d e f := Char_gadt.
Definition Caml_char {a b c d e f : Type} :
fmt a b c d e f → fmt (ascii → a) b c d e f := Caml_char_gadt.
Definition String
(padding_value : padding_gadt) (rest : fmt_gadt) : fmt_gadt :=
@String_gadt unit unit padding_value rest.
Definition Caml_string {a b c d e f x : Type} :
padding x (string → a) → fmt a b c d e f → fmt x b c d e f :=
Caml_string_gadt (a := a) (x := x).
Definition Int
(conversion : int_conv) (padding_value : padding_gadt)
(precision_value : precision_gadt) (rest : fmt_gadt) : fmt_gadt :=
@Int_gadt unit unit unit conversion padding_value precision_value rest.
Definition Int32 {a b c d e f x y : Type} :
int_conv → padding x y → precision y (int32 → a) → fmt a b c d e f →
fmt x b c d e f := Int32_gadt (a := a) (x := x) (y := y).
Definition Nativeint {a b c d e f x y : Type} :
int_conv → padding x y → precision y (nativeint → a) → fmt a b c d e f →
fmt x b c d e f := Nativeint_gadt (a := a) (x := x) (y := y).
Definition Int64
(conversion : int_conv) (padding_value : padding_gadt)
(precision_value : precision_gadt) (rest : fmt_gadt) : fmt_gadt :=
@Int64_gadt unit unit unit conversion padding_value precision_value rest.
Definition Float {a b c d e f x y : Type} :
float_conv → padding x y → precision y (float → a) → fmt a b c d e f →
fmt x b c d e f := Float_gadt (a := a) (x := x) (y := y).
Definition Bool {a b c d e f x : Type} :
padding x (bool → a) → fmt a b c d e f → fmt x b c d e f := Bool_gadt
(a := a) (x := x).
Definition Flush {a b c d e f : Type} : fmt a b c d e f → fmt a b c d e f :=
Flush_gadt.
Definition String_literal : string → fmt_gadt → fmt_gadt :=
String_literal_gadt.
Definition Char_literal : ascii → fmt_gadt → fmt_gadt :=
Char_literal_gadt.
Definition Format_arg {a b c d e f g h i j k l : Type} :
pad_option → fmtty g h i j k l → fmt a b c d e f →
fmt (format6 g h i j k l → a) b c d e f := Format_arg_gadt (g := g) (h := h)
(i := i) (j := j) (k := k) (l := l).
Definition Format_subst {a b c d e f g g2 h i j j2 k l : Type} :
pad_option → fmtty_rel g h i j k l g2 b c j2 d a → fmt a b c d e f →
fmt (format6 g h i j k l → g2) b c j2 e f := Format_subst_gadt (a := a)
(b := b) (c := c) (d := d) (g := g) (g2 := g2) (h := h) (i := i) (j := j)
(j2 := j2) (k := k) (l := l).
Definition Alpha {a b c d e f x : Type} :
fmt a b c d e f → fmt ((b → x → c) → x → a) b c d e f := Alpha_gadt.
Definition Theta {a b c d e f : Type} :
fmt a b c d e f → fmt ((b → c) → a) b c d e f := Theta_gadt.
Definition Formatting_lit {a b c d e f : Type} :
formatting_lit → fmt a b c d e f → fmt a b c d e f := Formatting_lit_gadt.
Definition Formatting_gen {a1 b c d1 e1 e2 f1 f2 : Type} :
formatting_gen a1 b c d1 e1 f1 → fmt f1 b c e1 e2 f2 → fmt a1 b c d1 e2 f2
:= Formatting_gen_gadt (a1 := a1) (b := b) (c := c) (d1 := d1) (e1 := e1)
(f1 := f1).
Definition Reader {a b c d e f x : Type} :
fmt a b c d e f → fmt (x → a) b c ((b → x) → d) e f := Reader_gadt.
Definition Scan_char_set {a b c d e f : Type} :
pad_option → char_set → fmt a b c d e f → fmt (string → a) b c d e f :=
Scan_char_set_gadt.
Definition Scan_get_counter {a b c d e f : Type} :
counter → fmt a b c d e f → fmt (int → a) b c d e f :=
Scan_get_counter_gadt.
Definition Scan_next_char {a b c d e f : Type} :
fmt a b c d e f → fmt (ascii → a) b c d e f := Scan_next_char_gadt.
Definition Ignored_param {a b c d e f x y : Type} :
ignored a b c d y x → fmt x b c y e f → fmt a b c d e f :=
Ignored_param_gadt (a := a) (b := b) (c := c) (d := d) (x := x) (y := y).
Definition Custom {a b c d e f x y : Type} :
custom_arity a x y → (unit → x) → fmt a b c d e f → fmt y b c d e f :=
Custom_gadt (a := a) (x := x) (y := y).
Definition End_of_format : fmt_gadt := End_of_format_gadt.
Definition Ignored_char {a b c d : Type} : ignored a b c d d a :=
Ignored_char_gadt.
Definition Ignored_caml_char {a b c d : Type} : ignored a b c d d a :=
Ignored_caml_char_gadt.
Definition Ignored_string {a b c d : Type} : pad_option → ignored a b c d d a :=
Ignored_string_gadt.
Definition Ignored_caml_string {a b c d : Type} :
pad_option → ignored a b c d d a := Ignored_caml_string_gadt.
Definition Ignored_int {a b c d : Type} :
int_conv → pad_option → ignored a b c d d a := Ignored_int_gadt.
Definition Ignored_int32 {a b c d : Type} :
int_conv → pad_option → ignored a b c d d a := Ignored_int32_gadt.
Definition Ignored_nativeint {a b c d : Type} :
int_conv → pad_option → ignored a b c d d a := Ignored_nativeint_gadt.
Definition Ignored_int64 {a b c d : Type} :
int_conv → pad_option → ignored a b c d d a := Ignored_int64_gadt.
Definition Ignored_float {a b c d : Type} :
pad_option → prec_option → ignored a b c d d a := Ignored_float_gadt.
Definition Ignored_bool {a b c d : Type} : pad_option → ignored a b c d d a :=
Ignored_bool_gadt.
Definition Ignored_format_arg {a b c d g h i j k l : Type} :
pad_option → fmtty g h i j k l → ignored a b c d d a :=
Ignored_format_arg_gadt (g := g) (h := h) (i := i) (j := j) (k := k) (l := l).
Definition Ignored_format_subst {a b c d e f : Type} :
pad_option → fmtty a b c d e f → ignored a b c d e f :=
Ignored_format_subst_gadt (a := a) (b := b) (c := c) (d := d) (e := e)
(f := f).
Definition Ignored_reader {a b c d x : Type} : ignored a b c ((b → x) → d) d a
:= Ignored_reader_gadt.
Definition Ignored_scan_char_set {a b c d : Type} :
pad_option → char_set → ignored a b c d d a := Ignored_scan_char_set_gadt.
Definition Ignored_scan_get_counter {a b c d : Type} :
counter → ignored a b c d d a := Ignored_scan_get_counter_gadt.
Definition Ignored_scan_next_char {a b c d : Type} : ignored a b c d d a :=
Ignored_scan_next_char_gadt.
Definition Format (format_value : fmt_gadt) (source : string) :
format6_gadt :=
@Format_gadt unit unit unit unit unit unit format_value source.
Parameter concat_fmtty : ∀
{a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 g1 g2 j1 j2 : Type},
fmtty_rel g1 b1 c1 j1 d1 a1 g2 b2 c2 j2 d2 a2 →
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel g1 b1 c1 j1 e1 f1 g2 b2 c2 j2 e2 f2.
Parameter erase_rel : ∀ {a b c d e f g h i j k l : Type},
fmtty_rel a b c d e f g h i j k l → fmtty a b c d e f.
Parameter concat_fmt : ∀ {a b c d e f g h : Type},
fmt a b c d e f → fmt f b c e g h → fmt a b c d g h.
End CamlinternalFormatBasics.
Global Instance string_eq_dec : EqDec (eq_setoid string) :=
String.string_dec.
Global Instance list_eq_dec {A : Type}
(A_eq_dec : EqDec (eq_setoid A))
: EqDec (eq_setoid (list A)) :=
List.list_eq_dec (@equiv_dec A (eq_setoid A) A_eq_dec).
Global Instance option_eq_dec {A : Type}
(A_eq_dec : EqDec (eq_setoid A))
: EqDec (eq_setoid (option A)).
Proof.
intros x y.
change ({x = y} + {x ≠ y}).
decide equality.
apply (@equiv_dec A (eq_setoid A) A_eq_dec).
Defined.
End Equality.
Module Char.
Global Instance eq_dec : EqDec (eq_setoid ascii) := ascii_dec.
Module Lt.
Definition t (c1 c2 : ascii) : Prop :=
N.lt (N_of_ascii c1) (N_of_ascii c2).
Lemma irreflexivity (c : ascii) : ¬ t c c.
apply N.lt_irrefl.
Qed.
Lemma transitivity (c1 c2 c3 : ascii) : t c1 c2 → t c2 c3 → t c1 c3.
apply N.lt_trans.
Qed.
Lemma N_of_ascii_inj (c1 c2 : ascii) : N_of_ascii c1 = N_of_ascii c2 → c1 = c2.
intro H.
rewrite <- (ascii_N_embedding c1).
rewrite <- (ascii_N_embedding c2).
rewrite H.
reflexivity.
Qed.
End Lt.
Global Instance strict_order : StrictOrder Lt.t :=
{|
StrictOrder_Irreflexive := Lt.irreflexivity;
StrictOrder_Transitive := Lt.transitivity;
|}.
Global Instance order_dec : OrderDec strict_order.
refine {|
compare := fun c1 c2 ⇒ (N_of_ascii c1 ?= N_of_ascii c2) % N;
compare_is_sound := fun c1 c2 ⇒ _;
|}.
destruct (N.compare_spec (N_of_ascii c1) (N_of_ascii c2)) as [Heq | Hlt | Hgt];
[apply CompEq | apply CompLt | apply CompGt].
- now apply Lt.N_of_ascii_inj.
- exact Hlt.
- exact Hgt.
Defined.
End Char.
Module Seq.
Reserved Notation "'t".
Inductive node (A : Set) : Set :=
| Nil : node A
| Cons : A → 't A → node A
where "'t" := (fun (T : Set) ⇒ unit → node T).
Definition t := 't.
Arguments Nil {_}.
Arguments Cons {_}.
End Seq.
Module String.
Definition length (s : string) : Z :=
Z.of_nat (String.length s).
Definition get (s : string) (n : Z) : ascii :=
match String.get (Z.to_nat n) s with
| None ⇒ "?" % char
| Some c ⇒ c
end.
Fixpoint _make (n : nat) (c : ascii) : string :=
match n with
| O ⇒ EmptyString
| S n ⇒ String c (_make n c)
end.
Fixpoint concat (sep : string) (sl : list string) : string :=
match sl with
| [] ⇒ ""
| [s] ⇒ s
| s :: sl ⇒ String.append (String.append s sep) (concat sep sl)
end.
Definition make (n : Z) (c : ascii) : string :=
_make (Z.to_nat n) c.
Definition sub (s : string) (start : Z) (length : Z) : string :=
s.
Definition escaped (s : string) : string :=
s.
Module Lt.
Inductive t : string → string → Prop :=
| EmptyString : ∀ c s, t EmptyString (String c s)
| StringStringLt : ∀ c1 s1 c2 s2,
N.lt (N_of_ascii c1) (N_of_ascii c2) → t (String c1 s1) (String c2 s2)
| StringStringEq : ∀ c1 s1 c2 s2,
c1 = c2 → t s1 s2 → t (String c1 s1) (String c2 s2).
Fixpoint irreflexivity (s : string) (H : t s s) : False.
inversion_clear H.
- apply (Char.Lt.irreflexivity H0).
- apply (irreflexivity _ H1).
Qed.
Fixpoint transitivity (s1 s2 s3 : string) (H12 : t s1 s2) (H23 : t s2 s3) : t s1 s3.
inversion H12; inversion H23; try apply EmptyString; try congruence.
- apply StringStringLt.
apply N.lt_trans with (m := N_of_ascii c2); congruence.
- apply StringStringLt; congruence.
- apply StringStringLt; congruence.
- apply StringStringEq; try congruence.
replace s4 with s5 in × by congruence.
now apply transitivity with (s2 := s5).
Qed.
End Lt.
Fixpoint ltb (s1 s2 : string) : bool :=
match s1, s2 with
| EmptyString, EmptyString ⇒ false
| EmptyString, String _ _ ⇒ true
| String _ _, EmptyString ⇒ false
| String c1 s1', String c2 s2' ⇒
let n1 := N_of_ascii c1 in
let n2 := N_of_ascii c2 in
(N.ltb n1 n2 || (N.eqb n1 n2 && ltb s1' s2')) % bool
end.
Fixpoint ltb_spec (s1 s2 : string) : Bool.reflect (Lt.t s1 s2) (ltb s1 s2).
destruct s1 as [| c1 s1]; destruct s2 as [| c2 s2]; simpl.
- apply Bool.ReflectF.
intro; now apply Lt.irreflexivity with (s := "" % string).
- apply Bool.ReflectT.
apply Lt.EmptyString.
- apply Bool.ReflectF.
intro H; inversion H.
- case_eq ((N_of_ascii c1 <? N_of_ascii c2)%N); intro H_lt; simpl.
+ apply Bool.ReflectT.
apply Lt.StringStringLt.
now apply N.ltb_lt.
+ case_eq ((N_of_ascii c1 =? N_of_ascii c2)%N); intro H_eq; simpl.
× destruct (ltb_spec s1 s2); constructor.
-- apply Lt.StringStringEq; trivial.
apply Char.Lt.N_of_ascii_inj.
now apply N.eqb_eq.
-- intro H; inversion H; try tauto.
assert ((N_of_ascii c1 <? N_of_ascii c2)%N = true) by
now apply N.ltb_lt.
congruence.
× apply Bool.ReflectF.
intro H; inversion H.
-- assert ((N_of_ascii c1 <? N_of_ascii c2)%N = true) by
now apply N.ltb_lt.
congruence.
-- assert ((N_of_ascii c1 =? N_of_ascii c2)%N = true) by
(apply N.eqb_eq; congruence).
congruence.
Qed.
Fixpoint ltb_or_eqb_or_gtb
(s1 s2 : string)
(H_nltb : ltb s1 s2 = false)
(H_neqb : String.eqb s1 s2 = false)
: ltb s2 s1 = true.
destruct s1 as [| c1 s1]; destruct s2 as [| c2 s2]; simpl in *; try congruence.
destruct (Bool.orb_false_elim _ _ H_nltb) as [H_c1c2 H].
case_eq ((N_of_ascii c1 ?= N_of_ascii c2)%N); intro H_comp_c1c2.
- assert (H_eq_c1c2 : N_of_ascii c1 = N_of_ascii c2) by
now apply N.compare_eq_iff.
replace ((N_of_ascii c2 =? N_of_ascii c1)%N) with true by (
symmetry;
apply N.eqb_eq;
congruence
).
rewrite ltb_or_eqb_or_gtb.
+ apply Bool.orb_true_r.
+ destruct (proj1 (Bool.andb_false_iff _ _) H); trivial.
assert (H_eq_c1c2_bis := proj2 (N.eqb_eq _ _) H_eq_c1c2).
congruence.
+ assert (H_eqb_c1c2 : (c1 =? c2)%char = true) by (
apply Ascii.eqb_eq;
now apply Char.Lt.N_of_ascii_inj
).
now rewrite H_eqb_c1c2 in H_neqb.
- assert ((N_of_ascii c1 <? N_of_ascii c2)%N = true) by (
apply N.ltb_lt;
now apply N.compare_lt_iff
).
congruence.
- assert (H_gt_c1c2 : (N_of_ascii c2 < N_of_ascii c1) % N) by
now apply N.compare_gt_iff.
now rewrite (proj2 (N.ltb_lt _ _) H_gt_c1c2).
Qed.
Global Instance strict_order : StrictOrder Lt.t := {|
StrictOrder_Irreflexive := Lt.irreflexivity;
StrictOrder_Transitive := Lt.transitivity;
|}.
Global Instance order_dec : OrderDec strict_order.
refine {|
compare := fun s1 s2 ⇒
if String.eqb s1 s2 then
Eq
else if ltb s1 s2 then
Lt
else
Gt;
compare_is_sound := fun s1 s2 ⇒ _;
|}.
case_eq (String.eqb s1 s2); intro H_eq.
- apply CompEq.
now apply String.eqb_eq.
- case_eq (ltb s1 s2); intro H_lt.
+ apply CompLt.
apply (ltb_spec _ _ H_lt).
+ apply CompGt.
apply (ltb_spec _ _ (ltb_or_eqb_or_gtb _ _ H_lt H_eq)).
Defined.
End String.
Module CamlinternalFormatBasics.
Inductive padty : Type :=
| Left : padty
| Right : padty
| Zeros : padty.
Inductive int_conv : Type :=
| Int_d : int_conv
| Int_pd : int_conv
| Int_sd : int_conv
| Int_i : int_conv
| Int_pi : int_conv
| Int_si : int_conv
| Int_x : int_conv
| Int_Cx : int_conv
| Int_X : int_conv
| Int_CX : int_conv
| Int_o : int_conv
| Int_Co : int_conv
| Int_u : int_conv.
Inductive float_conv : Type :=
| Float_f : float_conv
| Float_pf : float_conv
| Float_sf : float_conv
| Float_e : float_conv
| Float_pe : float_conv
| Float_se : float_conv
| Float_E : float_conv
| Float_pE : float_conv
| Float_sE : float_conv
| Float_g : float_conv
| Float_pg : float_conv
| Float_sg : float_conv
| Float_G : float_conv
| Float_pG : float_conv
| Float_sG : float_conv
| Float_F : float_conv
| Float_h : float_conv
| Float_ph : float_conv
| Float_sh : float_conv
| Float_H : float_conv
| Float_pH : float_conv
| Float_sH : float_conv.
Definition char_set : Type := string.
Inductive counter : Type :=
| Line_counter : counter
| Char_counter : counter
| Token_counter : counter.
Reserved Notation "'padding".
Inductive padding_gadt : Type :=
| No_padding_gadt : padding_gadt
| Lit_padding_gadt : padty → int → padding_gadt
| Arg_padding_gadt : padty → padding_gadt
where "'padding" := (fun (_ _ : Type) ⇒ padding_gadt).
Definition padding := 'padding.
Definition No_padding : padding_gadt := No_padding_gadt.
Definition Lit_padding : padty → int → padding_gadt := Lit_padding_gadt.
Definition Arg_padding {a : Type} : padty → padding (int → a) a :=
Arg_padding_gadt.
Definition pad_option : Type := option int.
Reserved Notation "'precision".
Inductive precision_gadt : Type :=
| No_precision_gadt : precision_gadt
| Lit_precision_gadt : int → precision_gadt
| Arg_precision_gadt : precision_gadt
where "'precision" := (fun (_ _ : Type) ⇒ precision_gadt).
Definition precision := 'precision.
Definition No_precision : precision_gadt := No_precision_gadt.
Definition Lit_precision {a : Type} : int → precision a a := Lit_precision_gadt.
Definition Arg_precision {a : Type} : precision (int → a) a :=
Arg_precision_gadt.
Definition prec_option : Type := option int.
Reserved Notation "'custom_arity".
Inductive custom_arity_gadt : Type :=
| Custom_zero_gadt : custom_arity_gadt
| Custom_succ_gadt : custom_arity_gadt → custom_arity_gadt
where "'custom_arity" := (fun (_ _ _ : Type) ⇒ custom_arity_gadt).
Definition custom_arity := 'custom_arity.
Definition Custom_zero {a : Type} : custom_arity a string a := Custom_zero_gadt.
Definition Custom_succ {a b c x : Type} :
custom_arity a b c → custom_arity a (x → b) (x → c) := Custom_succ_gadt.
Inductive block_type : Type :=
| Pp_hbox : block_type
| Pp_vbox : block_type
| Pp_hvbox : block_type
| Pp_hovbox : block_type
| Pp_box : block_type
| Pp_fits : block_type.
Inductive formatting_lit : Type :=
| Close_box : formatting_lit
| Close_tag : formatting_lit
| Break : string → int → int → formatting_lit
| FFlush : formatting_lit
| Force_newline : formatting_lit
| Flush_newline : formatting_lit
| Magic_size : string → int → formatting_lit
| Escaped_at : formatting_lit
| Escaped_percent : formatting_lit
| Scan_indic : ascii → formatting_lit.
Reserved Notation "'formatting_gen".
Reserved Notation "'fmtty_rel".
Reserved Notation "'fmtty".
Reserved Notation "'fmt".
Reserved Notation "'ignored".
Reserved Notation "'format6".
Inductive formatting_gen_gadt : Type :=
| Open_tag_gadt : ∀ {a b c d e f : Type},
'format6 a b c d e f → formatting_gen_gadt
| Open_box_gadt : ∀ {a b c d e f : Type},
'format6 a b c d e f → formatting_gen_gadt
with fmtty_rel_gadt : Type :=
| Char_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| String_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Int_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Int32_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Nativeint_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Int64_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Float_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Bool_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Format_arg_ty_gadt : ∀ {g h i j k l : Type},
'fmtty g h i j k l → fmtty_rel_gadt → fmtty_rel_gadt
| Format_subst_ty_gadt :
fmtty_rel_gadt → fmtty_rel_gadt → fmtty_rel_gadt → fmtty_rel_gadt
| Alpha_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Theta_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Any_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Reader_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| Ignored_reader_ty_gadt : fmtty_rel_gadt → fmtty_rel_gadt
| End_of_fmtty_gadt : fmtty_rel_gadt
with fmt_gadt : Type :=
| Char_gadt : fmt_gadt → fmt_gadt
| Caml_char_gadt : fmt_gadt → fmt_gadt
| String_gadt : ∀ {a x : Type},
padding x (string → a) → fmt_gadt → fmt_gadt
| Caml_string_gadt : ∀ {a x : Type},
padding x (string → a) → fmt_gadt → fmt_gadt
| Int_gadt : ∀ {a x y : Type},
int_conv → padding x y → precision y (int → a) → fmt_gadt → fmt_gadt
| Int32_gadt : ∀ {a x y : Type},
int_conv → padding x y → precision y (int32 → a) → fmt_gadt → fmt_gadt
| Nativeint_gadt : ∀ {a x y : Type},
int_conv → padding x y → precision y (nativeint → a) → fmt_gadt →
fmt_gadt
| Int64_gadt : ∀ {a x y : Type},
int_conv → padding x y → precision y (int64 → a) → fmt_gadt → fmt_gadt
| Float_gadt : ∀ {a x y : Type},
float_conv → padding x y → precision y (float → a) → fmt_gadt → fmt_gadt
| Bool_gadt : ∀ {a x : Type}, padding x (bool → a) → fmt_gadt → fmt_gadt
| Flush_gadt : fmt_gadt → fmt_gadt
| String_literal_gadt : string → fmt_gadt → fmt_gadt
| Char_literal_gadt : ascii → fmt_gadt → fmt_gadt
| Format_arg_gadt : ∀ {g h i j k l : Type},
pad_option → 'fmtty g h i j k l → fmt_gadt → fmt_gadt
| Format_subst_gadt : ∀ {a b c d g g2 h i j j2 k l : Type},
pad_option → 'fmtty_rel g h i j k l g2 b c j2 d a → fmt_gadt → fmt_gadt
| Alpha_gadt : fmt_gadt → fmt_gadt
| Theta_gadt : fmt_gadt → fmt_gadt
| Formatting_lit_gadt : formatting_lit → fmt_gadt → fmt_gadt
| Formatting_gen_gadt : ∀ {a1 b c d1 e1 f1 : Type},
'formatting_gen a1 b c d1 e1 f1 → fmt_gadt → fmt_gadt
| Reader_gadt : fmt_gadt → fmt_gadt
| Scan_char_set_gadt : pad_option → char_set → fmt_gadt → fmt_gadt
| Scan_get_counter_gadt : counter → fmt_gadt → fmt_gadt
| Scan_next_char_gadt : fmt_gadt → fmt_gadt
| Ignored_param_gadt : ∀ {a b c d x y : Type},
'ignored a b c d y x → fmt_gadt → fmt_gadt
| Custom_gadt : ∀ {a x y : Type},
custom_arity a x y → (unit → x) → fmt_gadt → fmt_gadt
| End_of_format_gadt : fmt_gadt
with ignored_gadt : Type :=
| Ignored_char_gadt : ignored_gadt
| Ignored_caml_char_gadt : ignored_gadt
| Ignored_string_gadt : pad_option → ignored_gadt
| Ignored_caml_string_gadt : pad_option → ignored_gadt
| Ignored_int_gadt : int_conv → pad_option → ignored_gadt
| Ignored_int32_gadt : int_conv → pad_option → ignored_gadt
| Ignored_nativeint_gadt : int_conv → pad_option → ignored_gadt
| Ignored_int64_gadt : int_conv → pad_option → ignored_gadt
| Ignored_float_gadt : pad_option → prec_option → ignored_gadt
| Ignored_bool_gadt : pad_option → ignored_gadt
| Ignored_format_arg_gadt : ∀ {g h i j k l : Type},
pad_option → 'fmtty g h i j k l → ignored_gadt
| Ignored_format_subst_gadt : ∀ {a b c d e f : Type},
pad_option → 'fmtty a b c d e f → ignored_gadt
| Ignored_reader_gadt : ignored_gadt
| Ignored_scan_char_set_gadt : pad_option → char_set → ignored_gadt
| Ignored_scan_get_counter_gadt : counter → ignored_gadt
| Ignored_scan_next_char_gadt : ignored_gadt
with format6_gadt : Type :=
| Format_gadt : ∀ {a b c d e f : Type},
'fmt a b c d e f → string → format6_gadt
where "'formatting_gen" := (fun (_ _ _ _ _ _ : Type) ⇒ formatting_gen_gadt)
and "'fmtty_rel" := (fun (_ _ _ _ _ _ _ _ _ _ _ _ : Type) ⇒ fmtty_rel_gadt)
and "'fmtty" := (fun (t_a t_b t_c t_d t_e t_f : Type) ⇒
'fmtty_rel t_a t_b t_c t_d t_e t_f t_a t_b t_c t_d t_e t_f)
and "'fmt" := (fun (_ _ _ _ _ _ : Type) ⇒ fmt_gadt)
and "'ignored" := (fun (_ _ _ _ _ _ : Type) ⇒ ignored_gadt)
and "'format6" := (fun (_ _ _ _ _ _ : Type) ⇒ format6_gadt).
Definition formatting_gen := 'formatting_gen.
Definition fmtty_rel := 'fmtty_rel.
Definition fmtty := 'fmtty.
Definition fmt := 'fmt.
Definition ignored := 'ignored.
Definition format6 := 'format6.
Definition Open_tag {a b c d e f : Type} :
format6 a b c d e f → formatting_gen a b c d e f := Open_tag_gadt (a := a)
(b := b) (c := c) (d := d) (e := e) (f := f).
Definition Open_box {a b c d e f : Type} :
format6 a b c d e f → formatting_gen a b c d e f := Open_box_gadt (a := a)
(b := b) (c := c) (d := d) (e := e) (f := f).
Definition Char_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (ascii → a1) b1 c1 d1 e1 f1 (ascii → a2) b2 c2 d2 e2 f2 :=
Char_ty_gadt.
Definition String_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (string → a1) b1 c1 d1 e1 f1 (string → a2) b2 c2 d2 e2 f2 :=
String_ty_gadt.
Definition Int_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (int → a1) b1 c1 d1 e1 f1 (int → a2) b2 c2 d2 e2 f2 :=
Int_ty_gadt.
Definition Int32_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (int32 → a1) b1 c1 d1 e1 f1 (int32 → a2) b2 c2 d2 e2 f2 :=
Int32_ty_gadt.
Definition Nativeint_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (nativeint → a1) b1 c1 d1 e1 f1 (nativeint → a2) b2 c2 d2 e2 f2 :=
Nativeint_ty_gadt.
Definition Int64_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (int64 → a1) b1 c1 d1 e1 f1 (int64 → a2) b2 c2 d2 e2 f2 :=
Int64_ty_gadt.
Definition Float_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (float → a1) b1 c1 d1 e1 f1 (float → a2) b2 c2 d2 e2 f2 :=
Float_ty_gadt.
Definition Bool_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (bool → a1) b1 c1 d1 e1 f1 (bool → a2) b2 c2 d2 e2 f2 :=
Bool_ty_gadt.
Definition Format_arg_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 g h i j k l : Type}
:
fmtty g h i j k l → fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (format6 g h i j k l → a1) b1 c1 d1 e1 f1
(format6 g h i j k l → a2) b2 c2 d2 e2 f2 := Format_arg_ty_gadt (g := g)
(h := h) (i := i) (j := j) (k := k) (l := l).
Definition Format_subst_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 g g1 g2 h i j j1
j2 k l : Type} :
fmtty_rel g h i j k l g1 b1 c1 j1 d1 a1 →
fmtty_rel g h i j k l g2 b2 c2 j2 d2 a2 →
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (format6 g h i j k l → g1) b1 c1 j1 e1 f1
(format6 g h i j k l → g2) b2 c2 j2 e2 f2 := Format_subst_ty_gadt.
Definition Alpha_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 x : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel ((b1 → x → c1) → x → a1) b1 c1 d1 e1 f1
((b2 → x → c2) → x → a2) b2 c2 d2 e2 f2 := Alpha_ty_gadt.
Definition Theta_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel ((b1 → c1) → a1) b1 c1 d1 e1 f1 ((b2 → c2) → a2) b2 c2 d2 e2 f2
:= Theta_ty_gadt.
Definition Any_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 x : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (x → a1) b1 c1 d1 e1 f1 (x → a2) b2 c2 d2 e2 f2 := Any_ty_gadt.
Definition Reader_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 x : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel (x → a1) b1 c1 ((b1 → x) → d1) e1 f1 (x → a2) b2 c2
((b2 → x) → d2) e2 f2 := Reader_ty_gadt.
Definition Ignored_reader_ty {a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 x : Type} :
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel a1 b1 c1 ((b1 → x) → d1) e1 f1 a2 b2 c2 ((b2 → x) → d2) e2 f2 :=
Ignored_reader_ty_gadt.
Definition End_of_fmtty {b1 b2 c1 c2 d1 d2 f1 f2 : Type} :
fmtty_rel f1 b1 c1 d1 d1 f1 f2 b2 c2 d2 d2 f2 := End_of_fmtty_gadt.
Definition Char {a b c d e f : Type} :
fmt a b c d e f → fmt (ascii → a) b c d e f := Char_gadt.
Definition Caml_char {a b c d e f : Type} :
fmt a b c d e f → fmt (ascii → a) b c d e f := Caml_char_gadt.
Definition String
(padding_value : padding_gadt) (rest : fmt_gadt) : fmt_gadt :=
@String_gadt unit unit padding_value rest.
Definition Caml_string {a b c d e f x : Type} :
padding x (string → a) → fmt a b c d e f → fmt x b c d e f :=
Caml_string_gadt (a := a) (x := x).
Definition Int
(conversion : int_conv) (padding_value : padding_gadt)
(precision_value : precision_gadt) (rest : fmt_gadt) : fmt_gadt :=
@Int_gadt unit unit unit conversion padding_value precision_value rest.
Definition Int32 {a b c d e f x y : Type} :
int_conv → padding x y → precision y (int32 → a) → fmt a b c d e f →
fmt x b c d e f := Int32_gadt (a := a) (x := x) (y := y).
Definition Nativeint {a b c d e f x y : Type} :
int_conv → padding x y → precision y (nativeint → a) → fmt a b c d e f →
fmt x b c d e f := Nativeint_gadt (a := a) (x := x) (y := y).
Definition Int64
(conversion : int_conv) (padding_value : padding_gadt)
(precision_value : precision_gadt) (rest : fmt_gadt) : fmt_gadt :=
@Int64_gadt unit unit unit conversion padding_value precision_value rest.
Definition Float {a b c d e f x y : Type} :
float_conv → padding x y → precision y (float → a) → fmt a b c d e f →
fmt x b c d e f := Float_gadt (a := a) (x := x) (y := y).
Definition Bool {a b c d e f x : Type} :
padding x (bool → a) → fmt a b c d e f → fmt x b c d e f := Bool_gadt
(a := a) (x := x).
Definition Flush {a b c d e f : Type} : fmt a b c d e f → fmt a b c d e f :=
Flush_gadt.
Definition String_literal : string → fmt_gadt → fmt_gadt :=
String_literal_gadt.
Definition Char_literal : ascii → fmt_gadt → fmt_gadt :=
Char_literal_gadt.
Definition Format_arg {a b c d e f g h i j k l : Type} :
pad_option → fmtty g h i j k l → fmt a b c d e f →
fmt (format6 g h i j k l → a) b c d e f := Format_arg_gadt (g := g) (h := h)
(i := i) (j := j) (k := k) (l := l).
Definition Format_subst {a b c d e f g g2 h i j j2 k l : Type} :
pad_option → fmtty_rel g h i j k l g2 b c j2 d a → fmt a b c d e f →
fmt (format6 g h i j k l → g2) b c j2 e f := Format_subst_gadt (a := a)
(b := b) (c := c) (d := d) (g := g) (g2 := g2) (h := h) (i := i) (j := j)
(j2 := j2) (k := k) (l := l).
Definition Alpha {a b c d e f x : Type} :
fmt a b c d e f → fmt ((b → x → c) → x → a) b c d e f := Alpha_gadt.
Definition Theta {a b c d e f : Type} :
fmt a b c d e f → fmt ((b → c) → a) b c d e f := Theta_gadt.
Definition Formatting_lit {a b c d e f : Type} :
formatting_lit → fmt a b c d e f → fmt a b c d e f := Formatting_lit_gadt.
Definition Formatting_gen {a1 b c d1 e1 e2 f1 f2 : Type} :
formatting_gen a1 b c d1 e1 f1 → fmt f1 b c e1 e2 f2 → fmt a1 b c d1 e2 f2
:= Formatting_gen_gadt (a1 := a1) (b := b) (c := c) (d1 := d1) (e1 := e1)
(f1 := f1).
Definition Reader {a b c d e f x : Type} :
fmt a b c d e f → fmt (x → a) b c ((b → x) → d) e f := Reader_gadt.
Definition Scan_char_set {a b c d e f : Type} :
pad_option → char_set → fmt a b c d e f → fmt (string → a) b c d e f :=
Scan_char_set_gadt.
Definition Scan_get_counter {a b c d e f : Type} :
counter → fmt a b c d e f → fmt (int → a) b c d e f :=
Scan_get_counter_gadt.
Definition Scan_next_char {a b c d e f : Type} :
fmt a b c d e f → fmt (ascii → a) b c d e f := Scan_next_char_gadt.
Definition Ignored_param {a b c d e f x y : Type} :
ignored a b c d y x → fmt x b c y e f → fmt a b c d e f :=
Ignored_param_gadt (a := a) (b := b) (c := c) (d := d) (x := x) (y := y).
Definition Custom {a b c d e f x y : Type} :
custom_arity a x y → (unit → x) → fmt a b c d e f → fmt y b c d e f :=
Custom_gadt (a := a) (x := x) (y := y).
Definition End_of_format : fmt_gadt := End_of_format_gadt.
Definition Ignored_char {a b c d : Type} : ignored a b c d d a :=
Ignored_char_gadt.
Definition Ignored_caml_char {a b c d : Type} : ignored a b c d d a :=
Ignored_caml_char_gadt.
Definition Ignored_string {a b c d : Type} : pad_option → ignored a b c d d a :=
Ignored_string_gadt.
Definition Ignored_caml_string {a b c d : Type} :
pad_option → ignored a b c d d a := Ignored_caml_string_gadt.
Definition Ignored_int {a b c d : Type} :
int_conv → pad_option → ignored a b c d d a := Ignored_int_gadt.
Definition Ignored_int32 {a b c d : Type} :
int_conv → pad_option → ignored a b c d d a := Ignored_int32_gadt.
Definition Ignored_nativeint {a b c d : Type} :
int_conv → pad_option → ignored a b c d d a := Ignored_nativeint_gadt.
Definition Ignored_int64 {a b c d : Type} :
int_conv → pad_option → ignored a b c d d a := Ignored_int64_gadt.
Definition Ignored_float {a b c d : Type} :
pad_option → prec_option → ignored a b c d d a := Ignored_float_gadt.
Definition Ignored_bool {a b c d : Type} : pad_option → ignored a b c d d a :=
Ignored_bool_gadt.
Definition Ignored_format_arg {a b c d g h i j k l : Type} :
pad_option → fmtty g h i j k l → ignored a b c d d a :=
Ignored_format_arg_gadt (g := g) (h := h) (i := i) (j := j) (k := k) (l := l).
Definition Ignored_format_subst {a b c d e f : Type} :
pad_option → fmtty a b c d e f → ignored a b c d e f :=
Ignored_format_subst_gadt (a := a) (b := b) (c := c) (d := d) (e := e)
(f := f).
Definition Ignored_reader {a b c d x : Type} : ignored a b c ((b → x) → d) d a
:= Ignored_reader_gadt.
Definition Ignored_scan_char_set {a b c d : Type} :
pad_option → char_set → ignored a b c d d a := Ignored_scan_char_set_gadt.
Definition Ignored_scan_get_counter {a b c d : Type} :
counter → ignored a b c d d a := Ignored_scan_get_counter_gadt.
Definition Ignored_scan_next_char {a b c d : Type} : ignored a b c d d a :=
Ignored_scan_next_char_gadt.
Definition Format (format_value : fmt_gadt) (source : string) :
format6_gadt :=
@Format_gadt unit unit unit unit unit unit format_value source.
Parameter concat_fmtty : ∀
{a1 a2 b1 b2 c1 c2 d1 d2 e1 e2 f1 f2 g1 g2 j1 j2 : Type},
fmtty_rel g1 b1 c1 j1 d1 a1 g2 b2 c2 j2 d2 a2 →
fmtty_rel a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 →
fmtty_rel g1 b1 c1 j1 e1 f1 g2 b2 c2 j2 e2 f2.
Parameter erase_rel : ∀ {a b c d e f g h i j k l : Type},
fmtty_rel a b c d e f g h i j k l → fmtty a b c d e f.
Parameter concat_fmt : ∀ {a b c d e f g h : Type},
fmt a b c d e f → fmt f b c e g h → fmt a b c d g h.
End CamlinternalFormatBasics.