Library VerifiedExtraction.Benchmarks.end_to_end
From MetaRocq Require Import Template.Ast.
Require Import Arith List.
Import ListNotations.
Require Import Arith List.
Import ListNotations.
VST specs for compiled Rocq programs
Axiom (eval : Ast.term → Ast.term).
Class Rep (A : Type) :=
{
rep : A → Ast.term → Prop
}.
Fixpoint nat_rep (n : nat) (v : Ast.term) : Prop :=
match n with
| O ⇒
match v with
| Ast.tConstruct (Ast.mkInd "Stdlib.Init.Datatypes.nat" 0) 0 ⇒ True
| _ ⇒ False
end
| S n ⇒
match v with
| Ast.tApp (Ast.tConstruct (Ast.mkInd "Stdlib.Init.Datatypes.nat" 0) 1) [x] ⇒
nat_rep n x
| _ ⇒ False
end
end.
Instance NatRep : Rep nat := { rep n v := nat_rep n (eval v) }.
Fixpoint list_rep {A : Type} `{Rep A} (l : list A) (v : Ast.term) : Prop :=
match l with
| [] ⇒
match v with
| Ast.tConstruct (Ast.mkInd "Stdlib.Init.Datatypes.list" 0) 0 ⇒ True
| _ ⇒ False
end
| hd :: tl ⇒
match v with
| Ast.tApp (Ast.tConstruct (Ast.mkInd "Stdlib.Init.Datatypes.list" 0) 1) [typ; vhd; vtl] ⇒
rep hd vhd ∧ list_rep tl vtl
| _ ⇒ False
end
end.
Instance ListRep {A : Type} `{Rep A} : Rep (list A) := { rep l v := list_rep l (eval v) }.
Instance ArrowRep {A B : Type} `{Rep A} `{Rep B} : Rep (A → B) :=
{ rep f t :=
∀ (a : A) (v : Ast.term), rep a v → rep (f a) (eval (Ast.tApp t [v]))
}.
Instance ProdRep (B : Type → Type) `{∀ (A : Type) (H : Rep A), Rep (B A)}
: Rep (∀ (A : Type), B A) :=
{ rep f t :=
∀ (A : Type) `{Rep A}, rep (f A) (eval (Ast.tApp t [qUnit]))
}.
Quote Definition qUnit := tt.
Instance ProdRep (B : Type → Type) `{∀ (A : Type) (H : Rep A), Rep (B A)}
: Rep (∀ (A : Type), B A) :=
{ rep f t :=
∀ (A : Type) `{Rep A}, rep (f A) (eval (Ast.tApp t [qUnit]))
}.
Instance ProdRep (B : Type → Type) `{∀ (A : Type) (H : Rep A), Rep (B A)}
: Rep (∀ (A : Type), B A) :=
{ rep f t :=
∀ (A : Type) `{Rep A}, rep (f A) (eval (Ast.tApp t [qUnit]))
}.