forked from thanhnguyen-aws/plausible
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDerivePermutationGenerator.lean
More file actions
85 lines (83 loc) · 3.06 KB
/
Copy pathDerivePermutationGenerator.lean
File metadata and controls
85 lines (83 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import Plausible.Chamelean.DeriveConstrainedProducer
import Plausible.Chamelean.ArbitrarySizedSuchThat
import Test.CommonDefinitions.Permutation
/--
info: Try this generator: instance : ArbitrarySizedSuchThat (List Nat) (fun l_1 => Permutation l_1 l'_1) where
arbitrarySizedST :=
let rec aux_arb (initSize : Nat) (size : Nat) (l'_1 : List Nat) : OptionT Plausible.Gen (List Nat) :=
match size with
| Nat.zero =>
OptionTGen.backtrack
[(1,
match l'_1 with
| List.nil => return List.nil
| _ => OptionT.fail),
(1,
match l'_1 with
| List.cons x (List.cons y l) => return List.cons y (List.cons x l)
| _ => OptionT.fail)]
| Nat.succ size' =>
OptionTGen.backtrack
[(1,
match l'_1 with
| List.nil => return List.nil
| _ => OptionT.fail),
(1,
match l'_1 with
| List.cons x (List.cons y l) => return List.cons y (List.cons x l)
| _ => OptionT.fail),
(Nat.succ size',
match l'_1 with
| List.cons x l' => do
let l ← aux_arb initSize size' l';
return List.cons x l
| _ => OptionT.fail),
(Nat.succ size', do
let l' ← aux_arb initSize size' l'_1;
do
let l_1 ← aux_arb initSize size' l';
return l_1)]
fun size => aux_arb size size l'_1
-/
#guard_msgs(info, drop warning) in
#derive_generator (fun (l : List Nat) => Permutation l l')
/--
info: Try this generator: instance : ArbitrarySizedSuchThat (List Nat) (fun l_1 => Permutation l'_1 l_1) where
arbitrarySizedST :=
let rec aux_arb (initSize : Nat) (size : Nat) (l'_1 : List Nat) : OptionT Plausible.Gen (List Nat) :=
match size with
| Nat.zero =>
OptionTGen.backtrack
[(1,
match l'_1 with
| List.nil => return List.nil
| _ => OptionT.fail),
(1,
match l'_1 with
| List.cons y (List.cons x l) => return List.cons x (List.cons y l)
| _ => OptionT.fail)]
| Nat.succ size' =>
OptionTGen.backtrack
[(1,
match l'_1 with
| List.nil => return List.nil
| _ => OptionT.fail),
(1,
match l'_1 with
| List.cons y (List.cons x l) => return List.cons x (List.cons y l)
| _ => OptionT.fail),
(Nat.succ size',
match l'_1 with
| List.cons x l => do
let l' ← aux_arb initSize size' l;
return List.cons x l'
| _ => OptionT.fail),
(Nat.succ size', do
let l' ← aux_arb initSize size' l'_1;
do
let l_1 ← aux_arb initSize size' l';
return l_1)]
fun size => aux_arb size size l'_1
-/
#guard_msgs(info, drop warning) in
#derive_generator (fun (l : List Nat) => Permutation l' l)