statement stringlengths 1 1.39k | proof stringlengths 0 4.58k | type stringclasses 21
values | symbolic_name stringlengths 1 49 | library stringclasses 18
values | filename stringclasses 100
values | imports listlengths 0 26 | deps listlengths 0 23 | docstring stringlengths 0 2.01k | source_url stringclasses 1
value | commit stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|
main | := runTests [
qc "example" prop_example
]. | Definition | main | test | test/mutation.v | [
"QuickChick",
"Coq",
"List",
"String",
"ExtrOcamlNatInt",
"ListNotations"
] | [
"prop_example",
"qc",
"runTests"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
foo {A : Type} | :=
| bar : A -> foo -> foo
| baz : foo
. | Inductive | foo | test | test/plugin.v | [
"QuickChick",
"Coq",
"Derive",
"MonadNotation",
"BindOptNotation",
"mathcomp",
"ssreflect",
"ssrnat",
"div"
] | [] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
qux : Type | :=
| Qux: forall {A: Type}, A -> qux. | Inductive | qux | test | test/plugin.v | [
"QuickChick",
"Coq",
"Derive",
"MonadNotation",
"BindOptNotation",
"mathcomp",
"ssreflect",
"ssrnat",
"div"
] | [] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
quux: qux -> bool | :=
fun a => match a with | Qux a => true end. | Definition | quux | test | test/plugin.v | [
"QuickChick",
"Coq",
"Derive",
"MonadNotation",
"BindOptNotation",
"mathcomp",
"ssreflect",
"ssrnat",
"div"
] | [
"qux"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
a : G nat | :=
ret 1. | Definition | a | test | test/plugin.v | [
"QuickChick",
"Coq",
"Derive",
"MonadNotation",
"BindOptNotation",
"mathcomp",
"ssreflect",
"ssrnat",
"div"
] | [
"nat"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
b : G nat | :=
v <- a ;;
ret v. | Definition | b | test | test/plugin.v | [
"QuickChick",
"Coq",
"Derive",
"MonadNotation",
"BindOptNotation",
"mathcomp",
"ssreflect",
"ssrnat",
"div"
] | [
"nat"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
c : G (option nat) | :=
ret (Some 42). | Definition | c | test | test/plugin.v | [
"QuickChick",
"Coq",
"Derive",
"MonadNotation",
"BindOptNotation",
"mathcomp",
"ssreflect",
"ssrnat",
"div"
] | [
"nat"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
d : G (option nat) | :=
v <-- c;;
ret (Some v). | Definition | d | test | test/plugin.v | [
"QuickChick",
"Coq",
"Derive",
"MonadNotation",
"BindOptNotation",
"mathcomp",
"ssreflect",
"ssrnat",
"div"
] | [
"nat"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
int | := nat. | Definition | int | test | test/plugin.v | [
"QuickChick",
"Coq",
"Derive",
"MonadNotation",
"BindOptNotation",
"mathcomp",
"ssreflect",
"ssrnat",
"div"
] | [
"nat"
] | Test extraction hack (substitute type int = int) | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
teh | := fun x : int => Nat.eqb x x. | Definition | teh | test | test/plugin.v | [
"QuickChick",
"Coq",
"Derive",
"MonadNotation",
"BindOptNotation",
"mathcomp",
"ssreflect",
"ssrnat",
"div"
] | [
"int"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
Tree A | :=
| Leaf : Tree A
| Node : A -> Tree A -> Tree A -> Tree A. | Inductive | Tree | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [] | Let's revisit our favorite datatype, binary trees: | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
Dec_Eq (A : Type) | := { dec_eq : forall (x y : A), decidable (x =
y) }. | Class | Dec_Eq | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"dec_eq"
] | The most common use of the Dec class is boolean equality
testing. That is the purpose of the Dec_Eq typeclass. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
Dec_Eq_Tree {A} `{Dec_Eq A} : Dec_Eq (Tree A). | Proof. dec_eq. Defined. | Instance | Dec_Eq_Tree | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"Dec_Eq",
"Tree",
"dec_eq"
] | For the Dec_Eq class in particular, QuickChick provides a useful
tactic for using the Coq-provided `decide equality` tactic in
conjunction with existing Dec_Eq instances, to automate its
construction. For example, for our Tree example we can invoke `dec_eq`, assuming our type A is also testable for equality --- note th... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
mirror {A : Type} (t : Tree A) : Tree A | :=
match t with
| Leaf => Leaf
| Node x l r => Node x (mirror r) (mirror l)
end. | Fixpoint | mirror | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"Tree"
] | Armed with all these instances, we can now automatically test
properties of trees. For example, in the BasicUsage tutorial we saw
a `mirror` function: | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
faulty_mirrorP (t : Tree nat) | :=
mirror t = t?. | Definition | faulty_mirrorP | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"Tree",
"mirror",
"nat"
] | Along with a faulty mirror property, specialized
to nat for simpler testing: | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
balanced {A} : nat -> Tree A -> Prop | :=
| B0 : balanced 0 Leaf
| B1 : balanced 1 Leaf
| BS : forall n x l r,
balanced n l -> balanced n r ->
balanced (S n) (Node x l r). | Inductive | balanced | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"Tree",
"nat"
] | Another very common occurrence in Coq is to have
complex inductive definitions that both constrain
the inputs of theorems, and are used in the conclusion.
For a complete example, we refer the user to the
stlc tutorial. For here, let's consider the simpler
case of balanced trees of height `n`, wher... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
insert {A} (x : A) (t : Tree A) : Tree A | :=
match t with
| Leaf => Node x Leaf Leaf
| Node y l r => Node y (insert x l) r
end. | Fixpoint | insert | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"Tree"
] | When implementing a data structure such as AVL trees, we would
ensure that a balanced tree remains balanced after inserting an
element with intricate rebalancing operations.
Here, let's encode a very naive insertion function that always inserts elements on the
leftmost path, and see how QuickChick can fig... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
all_trees_are_balanced (n : nat) (t : Tree nat) | :=
balanced n t ?? 10. | Definition | all_trees_are_balanced | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"Tree",
"balanced",
"nat"
] | So let's try to check our first (obviously false) property using derived
checkers: all trees (of natural numbers) are balanced. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
prop_gen_balanced_is_balanced | :=
let fuel := 10 in
(* Generate an arbitrary n *)
forAll (choose (0,5)) (fun (n : nat) =>
(* Generate an arbitrary balanced tree of height n *)
forAllMaybe (genSizedST (fun t => balanced n t) fuel) (fun (t : Tree nat) =>
(* Check the resulting tree is balanced. *)
balanced n t ?? fuel)). | Definition | prop_gen_balanced_is_balanced | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"Tree",
"balanced",
"choose",
"forAll",
"forAllMaybe",
"nat"
] | Now we can use this generator and the checker above, to sanity check that
QuickChick has done the right thing: | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
balanced_preserves_balanced (fuel n x : nat) (t : Tree nat) | :=
(balanced n t ?? fuel) ==>? (balanced n (insert x t) ?? fuel). | Definition | balanced_preserves_balanced | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"Tree",
"balanced",
"insert",
"nat"
] | Perfect! Now let's try to write - and test - the property that insertion
preserves balanced. We will use the '==>?' combinator which combines two
option bools, treating failures in the precondition as a `None` - a
discarded test. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
prop_balanced_preserves_balanced (n : nat) | :=
let fuel := 10 in
(* Generate an arbitrary balanced tree of height n *)
forAllMaybe (genSizedST (fun t => balanced n t) fuel) (fun (t : Tree nat) =>
(* Generate an arbitrary integer x to insert *)
forAll (choose (0,10)) (fun x =>
balanced_preserves_balanced fuel n x t)). | Definition | prop_balanced_preserves_balanced | tutorials | tutorials/Automation.v | [
"QuickChick",
"mathcomp",
"ssrbool"
] | [
"Tree",
"balanced",
"balanced_preserves_balanced",
"choose",
"forAll",
"forAllMaybe",
"nat"
] | Naturally, no balanced trees of height 5 could even be generated!
However, we could use the derived constrained generators instead: | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
remove (x : nat) (l : list nat) : list nat | :=
match l with
| [] => []
| h::t => if Nat.eqb h x then t else h :: remove x t
end. | Fixpoint | remove | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"nat"
] | It is not uncommon during a verification effort to spend many
hours attempting to prove a slightly false theorem, only to result
in frustration when the mistake is realized and one needs to start
over. Other theorem provers have testing tools to quickly raise
one's confidence before embarking on the bod... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
removeP (x : nat) (l : list nat) : bool | :=
negb (existsb (fun y => x =? y) (remove x l)). | Definition | removeP | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"nat",
"negb",
"remove"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
remove_spec | :=
forall x l, ~ In x (remove x l). | Definition | remove_spec | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"In",
"remove"
] | Internally, the code is extracted to OCaml, compiled, and run. The
following output is presented in your terminal, CoqIDE [Messages] pane, or
Visual Studio Code [Info] pulldown menu tab:
<<
0
[0; 0]
Failed! After 17 tests and 12 shrinks
>>
The output signifies that if we use an input where [x] is [0]... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
Color | := Red | Green | Blue | Yellow. | Inductive | Color | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [] | The [Show] typeclass contains a single function [show] from some
type [A] to Coq's [string]. QuickChick provides default instances
for [string]s (the identity function), [nat], [bool], [Z],
etc. (via extraction to appropriate OCaml functions for
efficiency), as well as some common compound datatypes: li... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
show_color : Show Color | :=
{| show c :=
match c with
| Red => "Red"
| Green => "Green"
| Blue => "Blue"
| Yellow => "Yellow"
end
|}. | Instance | show_color | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Color",
"Show"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
genColor : G Color | :=
elems [ Red ; Green ; Blue ; Yellow ]. | Definition | genColor | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Color"
] | Armed with [elems], we can write the following simple [Color]
generator. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
showTree {A} `{_ : Show A} : Show (Tree A) | :=
{| show :=
let fix aux t :=
match t with
| Leaf => "Leaf"
| Node x l r => "Node (" ++ show x ++ ") (" ++ aux l ++ ") (" ++ aux r ++ ")"
end
in aux
|}. | Instance | showTree | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Show",
"Tree"
] | Before getting to generators for trees, we give a simple [Show]
instance. The rather inconvenient need for a local [let fix]
declaration stems from the fact that Coq's typeclasses (unlike
Haskell's) are not automatically recursive. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
genTreeSized {A} (sz : nat) (g : G A) : G (Tree A) | :=
match sz with
| O => returnGen Leaf
| S sz' => oneOf [ returnGen Leaf ;
liftGen3 Node g (genTreeSized sz' g) (genTreeSized sz' g)
]
end. | Fixpoint | genTreeSized | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Tree",
"liftGen3",
"nat",
"returnGen"
] | Of course, this fixpoint will not pass Coq's termination
check. Attempting to justify this fixpoint to oneself, one might
say that at some point the random generation will pick a [Leaf] so
it will eventually terminate. Sadly, in this case the expected
size of the generated Tree is infinite...
The s... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
genTreeSized' {A} (sz : nat) (g : G A) : G (Tree A) | :=
match sz with
| O => returnGen Leaf
| S sz' => freq [ (1, returnGen Leaf) ;
(sz, liftGen3 Node g (genTreeSized' sz' g) (genTreeSized' sz' g))
]
end. | Fixpoint | genTreeSized' | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Tree",
"liftGen3",
"nat",
"returnGen"
] | [freq] takes a list of generators, each one tagged with a natural
number that serves as the weight of that generator. In the
following example, a [Leaf] will be generated 1 / (sz + 1) of the
time, while a [Node] the remaining sz / (sz + 1) of the time. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
mirror {A : Type} (t : Tree A) : Tree A | :=
match t with
| Leaf => Leaf
| Node x l r => Node x (mirror r) (mirror l)
end. | Fixpoint | mirror | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Tree"
] | To showcase this generator, we will use the notion of mirroring a
tree: swapping its left and right subtrees recursively. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
eq_tree (t1 t2 : Tree nat) : bool | :=
match t1, t2 with
| Leaf, Leaf => true
| Node x1 l1 r1, Node x2 l2 r2 =>
Nat.eqb x1 x2 && eq_tree l1 l2 && eq_tree r1 r2
| _, _ => false
end. | Fixpoint | eq_tree | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Tree",
"nat"
] | We also need a simple structural equality on trees | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
mirrorP (t : Tree nat) | := eq_tree (mirror (mirror t)) t. | Definition | mirrorP | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Tree",
"eq_tree",
"mirror",
"nat"
] | One expects that [mirror] should be unipotent; mirroring a tree
twice yields the original tree. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
faultyMirrorP (t : Tree nat) | := eq_tree (mirror t) t. | Definition | faultyMirrorP | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Tree",
"eq_tree",
"mirror",
"nat"
] | QuickChick quickly responds that this property passed 10000 tests,
so we gain some confidence in its truth. But what would happend if
we had the *wrong* property? | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
shrinkTree {A} (s : A -> list A) (t : Tree A) : list (Tree A) | :=
match t with
| Leaf => []
| Node x l r => [l] ++ [r] ++
map (fun x' => Node x' l r) (s x) ++
map (fun l' => Node x l' r) (shrinkTree s l) ++
map (fun r' => Node x l r') (shrinkTree s r)
end. | Fixpoint | shrinkTree | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Tree",
"map"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
genTree {A} `{Gen A} : GenSized (Tree A) | :=
{| arbitrarySized n := genTreeSized n arbitrary |}. | Instance | genTree | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Gen",
"GenSized",
"Tree",
"genTreeSized"
] | [sized] receives a function that given a number produces a
generator, just like [genTreeSized'], and returns a generator that
uses the size information inside the [G] monad.
The [shrink] function is simply a shrinker like [shrinkTree]. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
shrTree {A} `{Shrink A} : Shrink (Tree A) | :=
{| shrink x := shrinkTree shrink x |}. | Instance | shrTree | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Shrink",
"Tree",
"shrinkTree"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
size {A} (t : Tree A) : nat | :=
match t with
| Leaf => O
| Node _ l r => 1 + size l + size r
end. | Fixpoint | size | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Tree",
"nat"
] | Earlier in this tutorial we claimed that [genTreeSized] produced
"too many" [Leaf]s. But how can we justify that? Just looking at
the result of [Sample] gives us an idea that something is going
wrong but just observing a handful of samples cannot realistically
provide statistical guarantees. That is whe... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
treeProp (g : nat -> G nat -> G (Tree nat)) n | :=
forAll (g n (choose (0,n))) (fun t =>
collect (size t) true). | Definition | treeProp | tutorials | tutorials/BasicUsage.v | [
"QuickChick",
"QcDefaultNotation",
"List",
"ZArith",
"ListNotations",
"String"
] | [
"Tree",
"choose",
"collect",
"forAll",
"nat",
"size"
] | If we were to write a dummy property to check our generators and
measure the size of generated trees, we could use [treeProp]
below. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
string | := list ascii. | Definition | string | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [] | This example is taken from the Logical Foundations Volume of Software Foundations textbook | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
reg_exp (T : Type) : Type | :=
| EmptySet
| EmptyStr
| Char (t : T)
| App (r1 r2 : reg_exp T)
| Union (r1 r2 : reg_exp T)
| Star (r : reg_exp T). | Inductive | reg_exp | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [] | We start with an inductive definion of the regular expression data type | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
EnumSizedreg_exp_SizedMonotonic T {_ : Enum T} :
SizedMonotonic (@enumSized _ (@EnumSizedreg_exp T _)). | Proof. derive_enum_SizedMonotonic. Qed. | Instance | EnumSizedreg_exp_SizedMonotonic | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"Enum",
"SizedMonotonic",
"derive_enum_SizedMonotonic"
] | After automatically generating the [EnumSized] instance, we can
generate correctness proofs. To do this proof we first define a
"set-of-outcomes" semantics for our enumerator.
In particular, the combinator [semEnumSize], with signature:
semEnumSize : forall {A : Type}, E A -> nat -> set A
maps an enum... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
EnumSizedreg_exp_SizeMonotonic T `{EnumMonotonic T}:
forall s, SizeMonotonic (@enumSized _ (@EnumSizedreg_exp T _) s). | Proof. derive_enum_SizeMonotonic. Qed. | Instance | EnumSizedreg_exp_SizeMonotonic | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"EnumMonotonic",
"SizeMonotonic",
"derive_enum_SizeMonotonic"
] | Monotonicity in the internal size parameter
--------------------------------------
We also prove that the enumerator is monotonic in the internal size
parameter. That is,
forall s s1 s2 : nat,
s1 <= s2 -> semEnumSize (enumSized s1) s \subset semEnumSize (enumSized s2) s
This property is captured... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
EnumSizedreg_expCorrect T `{EnumMonotonicCorrect T}:
CorrectSized (@enumSized _ EnumSizedreg_exp). | Proof. derive_enum_Correct. Qed. | Instance | EnumSizedreg_expCorrect | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"CorrectSized",
"EnumMonotonicCorrect",
"derive_enum_Correct"
] | Correctness
-----------
We use the two monotonicity properties to prove correctness.
For simple enumerators like this one, correctness states:
{ x | exists s s', x \in semEnumSize (enumSized s) s' } <--> [set: A]
That is, the set of elements that belongs to [semEnumSize (enumSized s) s']
for some si... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
app | := @app. | Definition | app | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
exp_match {T: Type} : list T -> reg_exp T -> Prop | :=
| MEmpty : [] =~ EmptyStr
| MChar x : [x] =~ (Char x)
| MApp s1 re1 s2 re2 :
s1 =~ re1 ->
s2 =~ re2 ->
s1 ++ s2 =~ (App re1 re2)
| MUnionL s1 re1 re2 :
s1 =~ re1 ->
s1 =~ (Union re1 re2)
| MUnionR re1 s2 re2 :
s2 =~ re2 ->
s2 =~ (Union re1 re2)
| MStar0 re : []... | Inductive | exp_match | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"reg_exp"
] | The following inductive relation holds whenever a string of
characters drawn from a set [T] matches a regular expression. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
DecOptexp_match_monotonic {T} `{_ : Dec_Eq T} `{_ : EnumMonotonic T} (m : list T) n :
DecOptSizeMonotonic (exp_match m n). | Proof. derive_mon. Qed. | Instance | DecOptexp_match_monotonic | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"DecOptSizeMonotonic",
"Dec_Eq",
"EnumMonotonic",
"derive_mon",
"exp_match"
] | We can now prove correctness of the derived checker.
Monotonicity
------------
As before, we need to show monotonicity. In particular, we show that
if the validity of a proposition has been decided, then the decision
will not change by providing more fuel. In particular:
forall (s1 s2 : nat) (b : b... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
DecOptexp_match_sound {T} `{_ : Dec_Eq T} `{_ : EnumMonotonicCorrect T} (m : list T) n :
DecOptSoundPos (exp_match m n). | Proof. derive_sound. Qed. | Instance | DecOptexp_match_sound | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"DecOptSoundPos",
"Dec_Eq",
"EnumMonotonicCorrect",
"derive_sound",
"exp_match"
] | Soundness and Completeness
--------------------------
Using monotonicity we can prove soundness and completeness.
Soundness states:
forall (P : Prop) (H : DecOpt P) (s : nat), decOpt s = Some true -> P
That is, is [decOpt s] is [true] for some [s], then [P] holds.
It is captured by the [DecOptSou... | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
DecOptexp_match_complete {T} `{_ : Dec_Eq T} `{_ : EnumMonotonicCorrect T} (m : list T) n :
DecOptCompletePos (exp_match m n). | Proof. derive_complete. Qed. | Instance | DecOptexp_match_complete | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"DecOptCompletePos",
"Dec_Eq",
"EnumMonotonicCorrect",
"derive_complete",
"exp_match"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
EnumSizedSuchThateq_SizedMonotonic X {_ : Enum X} {_ : Dec_Eq X} (n : X) :
SizedMonotonicOptFP (@enumSizeST _ _ (EnumSizedSuchThateq n)). | Proof. derive_enumST_SizedMonotonicFP. Qed. | Instance | EnumSizedSuchThateq_SizedMonotonic | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"Dec_Eq",
"Enum",
"SizedMonotonicOptFP",
"derive_enumST_SizedMonotonicFP"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
EnumSizedSuchThateq_SizeMonotonic X `{_ : EnumMonotonic X} {_ : Dec_Eq X} (n : X) :
forall s, SizeMonotonicOptFP (@enumSizeST _ _ (EnumSizedSuchThateq n) s). | Proof. derive_enumST_SizeMonotonicFP. Qed. | Instance | EnumSizedSuchThateq_SizeMonotonic | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"Dec_Eq",
"EnumMonotonic",
"SizeMonotonicOptFP",
"derive_enumST_SizeMonotonicFP"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 | |
EnumSizedSuchThatexp_match_SizedMonotonic {T} `{_ : Dec_Eq T} `{_ : EnumMonotonic T} e:
SizedMonotonicOptFP (@enumSizeST _ _ (EnumSizedSuchThatexp_match e)). | Proof. derive_enumST_SizedMonotonicFP. Qed. | Instance | EnumSizedSuchThatexp_match_SizedMonotonic | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"Dec_Eq",
"EnumMonotonic",
"SizedMonotonicOptFP",
"derive_enumST_SizedMonotonicFP"
] | As with the simple enumeration, before deriving correctness, we need to derive
monotonicity. | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
EnumSizedSuchThatexp_match_SizeMonotonic {T} `{_ : Dec_Eq T} `{_ : EnumMonotonic T} e :
forall s, SizeMonotonicOptFP (@enumSizeST _ _ (EnumSizedSuchThatexp_match e) s). | Proof. derive_enumST_SizeMonotonicFP. Qed. | Instance | EnumSizedSuchThatexp_match_SizeMonotonic | tutorials | tutorials/DerivingProofs.v | [
"Coq",
"Init.Nat",
"List",
"ListNotations",
"QuickChick",
"QcNotation",
"QcDefaultNotation",
"Coq.Strings.Ascii",
"EnumProofs",
"CheckerProofs"
] | [
"Dec_Eq",
"EnumMonotonic",
"SizeMonotonicOptFP",
"derive_enumST_SizeMonotonicFP"
] | https://github.com/QuickChick/QuickChick | 5a6c291b11e9affe059c0e1812612bc474d0a129 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.