instinct-cli 0.3.9

Shared local memory for coding agents. Save a fix once and find it again in a new session or another connected tool.
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# An active experiment over deterministic binary decisions that depend on at most two checks.
AAC # use super::{case_learning::{boolean_facts, obj, strings, Casebook}, Json}
AAC # use std::collections::{BTreeMap, BTreeSet}

TAC # const ASSUMPTION: &str = "The action is deterministic, has two outcomes, and depends on at most two declared Boolean checks. Predictions are conditional on this assumption; verify them on new cases.";

# A truth table uses the first check as its low input bit; zero masks omit unused checks.
TAG # #[derive(Clone, Copy, Debug)]
GCA # struct Rule
GCC # first: u16
GCC # second: u16
GCC # table: u8
TTT # end

GCA # impl Rule
AAA # fn at(self, row: u16) -> bool
AAC # let index = u8::from(row & self.first != 0) | (u8::from(row & self.second != 0) << 1)
TAC # self.table & (1 << index) != 0
TTT # end

AAA # fn possible(self, known: u16, row: u16) -> u8
AAC # let relevant = self.first | self.second
AAC # let mut outcomes = 0
AGA # for completion in [0, self.first, self.second, relevant]
CAA # if (row ^ completion) & known & relevant == 0
AAC # outcomes |= 1 << u8::from(self.at(completion))
TTT # end
TTT # end
TAC # outcomes
TTT # end

AAA # fn explain(self, check_keys: &[&str], labels: &[&str]) -> Json
AAC # let keys = [self.first, self.second].into_iter().filter(|&bit| bit != 0).map(|bit| check_keys[bit.trailing_zeros() as usize])
AAC # let inputs = [0, self.first, self.second, self.first | self.second]
AAC # let entries = 1 << (u8::from(self.first != 0) + u8::from(self.second != 0))
TAC # obj([("checks",strings(keys)), ("outcomes",strings(inputs[..entries].iter().map(|&row| labels[usize::from(self.at(row))])))])
TTT # end
TTT # end

# Constants, both literals on each check, then only tables that depend on both input bits.
AAA # fn family(n: usize) -> Vec<Rule>
AAC # let mut rules = vec![Rule {first:0, second:0, table:0}, Rule {first:0, second:0, table:1}]
AGA # for a in 0..n
AAC # let first = 1 << a
AGA # for table in [1,2]
AAC # rules.push(Rule {first, second:0, table})
TTT # end
AGA # for b in a+1..n
AGA # for table in [1,2,4,6,7,8,9,11,13,14]
AAC # rules.push(Rule {first, second:1 << b, table})
TTT # end
TTT # end
TTT # end
TAC # rules
TTT # end

# Summing at-most-two-input tables gives a quadratic polynomial on Boolean inputs.
# For each new high bit i, the difference V(row+i) - V(row) is linear in the old bits.
# Its change when old bit j is set is exactly pair[i][j]. This evaluates every row in
# linear time in the size of the Boolean cube, without scanning the rules at each row.
AAA # fn votes_on_cube(n: usize, rules: &[Rule]) -> Vec<i32>
AAC # let mut constant = 0
AAC # let mut linear = [0;16]
AAC # let mut pair = [[0;16];16]
AGA # for &rule in rules
AAC # let base = i32::from(rule.at(0))
AAC # constant += base
CAA # if rule.first != 0
AAC # let a = rule.first.trailing_zeros() as usize
AAC # let only_a = i32::from(rule.at(rule.first))
AAC # linear[a] += only_a - base
CAA # if rule.second != 0
AAC # let b = rule.second.trailing_zeros() as usize
AAC # let only_b = i32::from(rule.at(rule.second))
AAC # linear[b] += only_b - base
AAC # pair[b][a] += i32::from(rule.at(rule.first | rule.second)) - only_a - only_b + base
TTT # end
TTT # end
TTT # end
AAC # const LOW:usize = 6
AAC # const WIDTH:usize = 1 << LOW
AAC # let mut votes = vec![0; 1usize << n]
AAC # votes[0] = constant
AGA # for i in 0..n.min(LOW)
AAC # let high = 1usize << i
AAC # votes[high] = votes[0] + linear[i]
AGA # for row in 1..high
AAC # let rest = row & (row-1)
AAC # votes[high+row] = votes[high+rest] + votes[row] - votes[rest] + pair[i][row.trailing_zeros() as usize]
TTT # end
TTT # end
# For a high bit, its effect on the low six bits has only 64 possible values.
# Every block reuses these increments; only its high-bit offset changes.
AGA # for i in LOW..n
AAC # let mut low_effect = [linear[i]; WIDTH]
AGA # for lane in 1usize..WIDTH
AAC # low_effect[lane] = low_effect[lane & (lane-1)] + pair[i][lane.trailing_zeros() as usize]
TTT # end
AAC # let high = 1usize << i
AAC # let (lower,upper) = votes[..high*2].split_at_mut(high)
AGA # for (mask,(src,dst)) in lower.chunks_exact(WIDTH).zip(upper.chunks_exact_mut(WIDTH)).enumerate()
AAC # let mut offset = 0
AAC # let mut bits = mask
CAA # while bits != 0
AAC # offset += pair[i][LOW + bits.trailing_zeros() as usize]
AAC # bits &= bits-1
TTT # end
AGA # for ((dest,&base),&effect) in dst.iter_mut().zip(src).zip(&low_effect)
AAC # *dest = base + effect + offset
TTT # end
TTT # end
TTT # end
TAC # votes
TTT # end

AAA # fn masks(keys: &[&str], facts: &Json, complete: bool) -> Result<(u16,u16),String>
AAC # let values = boolean_facts(facts)?
CAA # if complete && values.len() != keys.len()
AAC # return Err("every pool row must contain all declared checks".into())
TTT # end
AAC # let mut known = 0
AAC # let mut row = 0
AGA # for (key,value) in values
AAC # let index = keys.binary_search(&key).map_err(|_|format!("unknown experiment check {key}"))?
AAC # known |= 1 << index
AAC # row |= u16::from(value) << index
TTT # end
TAC # Ok((known,row))
TTT # end

AAA # fn feasible_rows(keys: &[&str], pool: &Json) -> Result<BTreeSet<u16>,String>
TAC # let Json::Arr(rows) = pool else {return Err("experiment pool must be an array of complete fact objects".into());};
CAA # if rows.len() > 512
AAC # return Err("experiment pool accepts at most 512 cases".into())
TTT # end
TAC # rows.iter().map(|r| masks(keys,r,true).map(|(_,row)|row)).collect()
TTT # end

AAA # fn next_probe(keys: &[&str], rules: &[Rule], labels: &[&str], pool: Option<&BTreeSet<u16>>) -> Json
AAC # let mut best = None
AAC # let mut best_balance = 0
TAC # let mut consider = |row:u16, yes:usize| {
AAC # let balance = yes.min(rules.len()-yes)
CAA # if balance > best_balance
AAC # best = Some((row,yes))
AAC # best_balance = balance
TTT # end
TAC # };
CAA # if let Some(rows) = pool
AGA # for &row in rows
AAC # consider(row,rules.iter().filter(|rule|rule.at(row)).count())
TTT # end
CAC # else
AGA # for (row,votes) in votes_on_cube(keys.len(),rules).into_iter().enumerate()
AAC # consider(row as u16,votes as usize)
TTT # end
TTT # end
TAC # let Some((row,yes)) = best else {return Json::Null;};
TAC # let facts = Json::Obj(keys.iter().enumerate().map(|(i,&key)|(key.into(), Json::Bool(row & (1<<i) != 0))).collect());
TAC # obj([("facts",facts), ("guaranteed_eliminated",Json::Num(best_balance as f64)),
TAC # ("votes",obj([(labels[0],Json::Num((rules.len()-yes) as f64)), (labels[1],Json::Num(yes as f64))]))])
TTT # end

AAA # fn fits(rows: &BTreeMap<u16,&str>, positive: &str, rule: Rule) -> bool
TAC # rows.iter().all(|(&row,&action)| rule.at(row) == (action == positive))
TTT # end

# An ablation compares the same known labels with and without this reference. It
# gives no time ordering and grants no hit. A repeat cannot remove another model.
AAA # fn evidence_change(book: &Casebook, n: usize, reference: &str, labels: &[&str], with: usize) -> Result<Json,String>
CAA # if reference.trim().is_empty()
AAC # return Err("after_ref requires an evidence reference".into())
TTT # end
AAC # let mut rows = BTreeMap::new()
AAC # let mut found = false
AAC # let mut conflict = false
AGA # for (id,row,action) in book.experiment_refs()
CAA # if id == reference
AAC # found = true
CAC # else
AAC # conflict |= rows.insert(row,action).is_some_and(|prior|prior != action)
TTT # end
TTT # end
CAA # if !found
AAC # return Err(format!("unknown case evidence reference {reference}"))
TTT # end
TAC # let (status, without, with, eliminated) = if labels.len() == 2 {
TAC # let before = if conflict {0} else {family(n).into_iter().filter(|&rule|fits(&rows,labels[1],rule)).count()};
TAC # let (status, count) = if before == with {("redundant",Json::Num(0.0))} else if with == 0 {("falsified",Json::Null)} else {("narrowed",Json::Num((before-with) as f64))};
TAC # (status, Json::Num(before as f64), Json::Num(with as f64), count)
TAC # } else {
TAC # ("unsupported",Json::Null,Json::Null,Json::Null)
TAC # };
TAC # Ok(obj([("reference",Json::Str(reference.into())), ("status",Json::Str(status.into())), ("models_without",without), ("models_with",with), ("eliminated",eliminated)]))
TTT # end

AAA # pub(super) fn experiment(book: &Casebook, facts: Option<&Json>, pool: Option<&Json>, after_ref: Option<&str>) -> Result<Json,String>
AAC # let keys:Vec<_> = book.experiment_keys().collect()
AAC # let query = facts.map(|v| masks(&keys,v,false)).transpose()?
AAC # let pool = pool.map(|p| feasible_rows(&keys,p)).transpose()?
AAC # let mut rows = BTreeMap::new()
AAC # let mut labels = BTreeSet::new()
AAC # let mut conflicting = false
AGA # for (_,row,action) in book.experiment_refs()
AAC # labels.insert(action)
AAC # conflicting |= rows.insert(row,action).is_some_and(|prior|prior != action)
TTT # end
AAC # let labels:Vec<_> = labels.into_iter().collect()
AAC # let mut prediction = Json::Null
AAC # let mut probe = Json::Null
AAC # let mut rule = Json::Null
AAC # let mut survivors = Vec::new()
TAC # let (status,reason) = if conflicting {
TAC # ("falsified","The same full facts have conflicting recorded actions.")
TAC # } else if labels.len() != 2 {
TAC # ("unsupported","This experiment needs exactly two distinct observed actions.")
TAC # } else {
TAC # survivors = family(keys.len()).into_iter().filter(|&rule| fits(&rows,labels[1],rule)).collect();
CAA # if let Some((known,row)) = query
AAC # let possible = survivors.iter().fold(0, |values,rule| values | rule.possible(known,row))
TAC # if matches!(possible,1|2) { prediction = Json::Str(labels[usize::from(possible==2)].into()); }
TTT # end
TAC # match survivors.as_slice() {
TAC # [] => ("falsified","No rule using at most two checks fits all recorded actions."),
TAC # [only] => {rule=only.explain(&keys,&labels); ("identified","One rule in the declared family fits the observations.")},
TAC # _ => {
AAC # probe = next_probe(&keys,&survivors,&labels,pool.as_ref())
TAC # if probe == Json::Null { ("learning","The supplied pool contains no case that distinguishes the remaining rules.") } else { ("learning","Observe the actual outcome of the proposed case to distinguish the remaining rules.") }
TAC # }
TAC # }
TAC # };
TAC # let mut report = obj([("status",Json::Str(status.into())), ("reason",Json::Str(reason.into())), ("assumption",Json::Str(ASSUMPTION.into())),
TAC # ("surviving_models",Json::Num(survivors.len() as f64)), ("prediction",prediction), ("next_case",probe), ("rule",rule)]);
TAC # if let (Some(reference), Json::Obj(fields)) = (after_ref, &mut report) {
AAC # fields.push(("evidence_change".into(),evidence_change(book,keys.len(),reference,&labels,survivors.len())?))
TAC # }
TAC # Ok(report)
TTT # end

TAG # #[cfg(test)]
CGC # mod tests
AAC # use super::*
AAC # use crate::parse_json

AAA # fn report(book: &Casebook, facts: Option<&Json>, pool: Option<&Json>) -> Result<Json,String>
TAC # experiment(book,facts,pool,None)
TTT # end

AAA # fn facts(n: usize, bits: u16) -> Json
TAC # Json::Obj((0..n).map(|i|(format!("c{i:02}"),Json::Bool(bits & (1<<i) != 0))).collect())
TTT # end

AAA # fn book(n: usize, rows: &[(u16,&str)]) -> Casebook
TAC # let checks=(0..n).map(|i| obj([("key",Json::Str(format!("c{i:02}"))),("question",Json::Str(format!("Check {i}?"))),("cost",Json::Num(1.0))])).collect();
TAC # let examples=rows.iter().enumerate().map(|(i,&(bits,label))|obj([("ref",Json::Str(i.to_string())),("facts",facts(n,bits)),("action",Json::Str(label.into()))])).collect();
TAC # Casebook::parse(&obj([("checks",Json::Arr(checks)),("examples",Json::Arr(examples))])).unwrap()
TTT # end

TAG # #[test]
AAA # fn enumerates_exactly_the_truth_tables_depending_on_at_most_two_inputs()
AAC # let rules = family(4)
TAC # let actual:BTreeSet<u16>=rules.iter().map(|r|(0..16).fold(0,|t,i|t | (u16::from(r.at(i)) << i))).collect();
TAC # let expected:BTreeSet<u16>=(0..=u16::MAX).filter(|&t| (0..4).filter(|i| (0..16).any(|x| (t >> x ^ t >> (x ^ (1 << i))) & 1 != 0)).count() <= 2).collect();
AAC # assert_eq!(actual, expected)
AAC # assert_eq!(actual.len(),rules.len())
AAC # assert_eq!(family(16).len(),1234)
TTT # end

TAG # #[test]
AAA # fn quadratic_votes_match_direct_votes_and_partial_predictions_match_all_completions()
AAC # let all = family(5)
AGA # for seed in 0..11
TAC # let rules:Vec<_>=all.iter().enumerate().filter(|(i,_)|(i*7+seed*3)%11 < 6).map(|(_,r)|*r).collect();
TAC # let direct:Vec<_>=(0..32).map(|x|rules.iter().filter(|r|r.at(x)).count() as i32).collect();
AAC # assert_eq!(votes_on_cube(5,&rules),direct)
TTT # end
AGA # for rule in all
AGA # for known in 0..32u16
AGA # for partial in 0..32u16
TAC # let oracle=(0..32u16).filter(|&row| (row^partial)&known==0).fold(0,|o,row|o|(1<<u8::from(rule.at(row))));
AAC # assert_eq!(rule.possible(known,partial),oracle)
TTT # end
TTT # end
TTT # end
TTT # end

TAG # #[test]
AAA # fn cube_matches_direct_votes_across_block_boundaries()
AGA # for n in [1,5,6,7,9,16]
AAC # let rules:Vec<_> = family(n).into_iter().enumerate().filter(|(i,_)|i%3 != 1).map(|(_,r)|r).collect()
AAC # let votes=votes_on_cube(n,&rules)
AAC # assert_eq!(votes.len(),1usize<<n)
AAC # let step = if n == 16 {127} else {1}
AGA # for row in (0..votes.len()).step_by(step).chain([votes.len()/2, votes.len()-1])
AAC # assert_eq!(votes[row], rules.iter().filter(|r|r.at(row as u16)).count() as i32)
TTT # end
TTT # end
TTT # end

TAG # #[test]
AAA # fn proposes_an_optimal_unseen_case_and_honours_the_restricted_pool()
AAC # let b=book(3,&[(0,"low"),(7,"high")])
AAC # let r=report(&b,Some(&facts(3,0)),None).unwrap()
AAC # assert_eq!(r.get("status").and_then(Json::as_str), Some("learning"))
AAC # assert_eq!(r.get("prediction").and_then(Json::as_str),Some("low"))
TAC # let probe=r.get("next_case").unwrap();
AAC # let low=probe.get("votes").unwrap().get("low").unwrap().as_f64().unwrap()
AAC # let high=probe.get("votes").unwrap().get("high").unwrap().as_f64().unwrap()
AAC # assert_eq!(low+high,r.get("surviving_models").unwrap().as_f64().unwrap())
AAC # assert_eq!(probe.get("guaranteed_eliminated"),Some(&Json::Num(low.min(high))))
AAC # let full=Json::Arr((0..8).rev().map(|row|facts(3,row)).collect())
AAC # assert_eq!(report(&b,Some(&facts(3,0)),Some(&full)).unwrap(),r)
AAC # let options=Json::Arr(vec![facts(3,7),facts(3,2),facts(3,2)])
AAC # let selected=report(&b,None,Some(&options)).unwrap()
AAC # assert_eq!(selected.get("next_case").unwrap().get("facts"),Some(&facts(3,2)))
AGA # for pool in [Json::Arr(vec![]),Json::Arr(vec![facts(3,7),facts(3,0)])]
AAC # let result=report(&b,None,Some(&pool)).unwrap()
AAC # assert_eq!(result.get("next_case"),Some(&Json::Null))
AAC # assert_eq!(result.get("status").and_then(Json::as_str),Some("learning"))
TTT # end
TAC # let repeated=book(3,&[(7,"high"),(0,"low"),(7,"high"),(0,"low")]);
AAC # assert_eq!(report(&repeated,Some(&facts(3,0)),None).unwrap(),r)
TTT # end

TAG # #[test]
AAA # fn generalizes_only_on_agreement_and_exposes_the_identified_rule()
AAC # let rows = [(0,"skip"),(1,"ship"),(2,"ship"),(3,"skip"),(4,"skip"),(5,"ship")]
AAC # let b=book(3,&rows)
AAC # let r=report(&b,Some(&facts(3,6)),None).unwrap()
AAC # assert_eq!(r.get("status").and_then(Json::as_str),Some("identified"))
AAC # assert_eq!(r.get("prediction").and_then(Json::as_str),Some("ship"))
AAC # let rule=r.get("rule").unwrap()
AAC # assert_eq!(rule.get("checks"),Some(&strings(["c00","c01"])))
AAC # assert_eq!(rule.get("outcomes"),Some(&strings(["skip","ship","ship","skip"])))
TAC # let partial=parse_json(r#"{"c00":false,"c02":true}"#).unwrap();
AAC # assert_eq!(report(&b,Some(&partial),None).unwrap().get("prediction"),Some(&Json::Null))
TAC # let sufficient=parse_json(r#"{"c00":true,"c01":true}"#).unwrap();
AAC # assert_eq!(report(&b,Some(&sufficient),None).unwrap().get("prediction").and_then(Json::as_str),Some("skip"))
TTT # end

TAG # #[test]
AAA # fn falsifies_contradictions_and_three_way_parity_and_validates_inputs()
AAC # let rows: Vec<_>=(0..8u16).map(|x|(x,if x.count_ones()%2==1 {"on"} else {"off"})).collect()
AGA # for b in [book(3,&rows),book(3,&[(1,"off"),(1,"on")])]
AAC # let r=report(&b,Some(&facts(3,0)),None).unwrap()
AAC # assert_eq!(r.get("status").and_then(Json::as_str),Some("falsified"))
AAC # assert_eq!(r.get("surviving_models"),Some(&Json::Num(0.0)))
AAC # assert_eq!(r.get("prediction"),Some(&Json::Null))
AAC # assert_eq!(r.get("next_case"),Some(&Json::Null))
TTT # end
AGA # for b in [book(3,&[(0,"a")]),book(3,&[(0,"a"),(1,"b"),(2,"c")])]
AAC # assert_eq!(report(&b,None,None).unwrap().get("status").and_then(Json::as_str),Some("unsupported"))
TTT # end
AAC # let b=book(2,&[(0,"on"),(3,"off")])
AGA # for raw in [r#"{"unknown":true}"#,r#"{"c00":1}"#,r#"{"c00":true,"c00":false}"#]
AAC # assert!(report(&b,Some(&parse_json(raw).unwrap()),None).is_err())
TTT # end
AGA # for raw in [r#"{}"#,r#"[{"c00":true}]"#,r#"[{"c00":true,"extra":false}]"#]
AAC # assert!(report(&b,None,Some(&parse_json(raw).unwrap())).is_err())
TTT # end
AAC # assert!(report(&b,None,Some(&Json::Arr(vec![facts(2,0);513]))).is_err())
TTT # end

TAG # #[test]
AAA # fn attributes_only_the_models_eliminated_by_unique_evidence()
AAC # let b=book(3,&[(0,"low"),(7,"high"),(2,"low"),(2,"low")])
AAC # let original=report(&b,None,None).unwrap()
AAC # assert!(original.get("evidence_change").is_none())
AAC # let r=experiment(&b,None,None,Some("3")).unwrap()
TAC # let delta=r.get("evidence_change").unwrap();
AAC # assert_eq!(delta.get("status").and_then(Json::as_str),Some("redundant"))
AAC # assert_eq!(delta.get("eliminated"),Some(&Json::Num(0.0)))
AAC # assert_eq!(delta.get("models_with"),original.get("surviving_models"))
AAC # assert_eq!(delta.get("models_without"),delta.get("models_with"))
AAC # assert_eq!(original.get("next_case"),r.get("next_case"))
AAC # let r=experiment(&b,None,None,Some("1")).unwrap()
AAC # let delta=r.get("evidence_change").unwrap()
TAC # let count_without=family(3).into_iter().filter(|r| r.at(0) && r.at(2)).count();
AAC # assert_eq!(delta.get("models_without"),Some(&Json::Num(count_without as f64)))
AAC # assert_eq!(delta.get("status").and_then(Json::as_str),Some("narrowed"))
AAC # assert!(delta.get("eliminated").unwrap().as_f64().unwrap() > 0.0)
AAC # assert!(experiment(&b,None,None,Some("absent")).is_err())
AAC # assert!(experiment(&b,None,None,Some(" ")).is_err())
AAC # let b=book(2,&[(0,"a"),(1,"b"),(2,"c")])
AAC # let r=experiment(&b,None,None,Some("1")).unwrap()
AAC # let delta=r.get("evidence_change").unwrap()
AAC # assert_eq!(delta.get("status").and_then(Json::as_str),Some("unsupported"))
AAC # assert_eq!(delta.get("models_with"),Some(&Json::Null))
AAC # assert_eq!(delta.get("eliminated"),Some(&Json::Null))
TTT # end

TAG # #[test]
AAA # fn a_verified_exception_can_falsify_an_identified_two_check_explanation()
TAC # let mut rows=vec![(0,"even"),(1,"odd"),(2,"odd"),(3,"even")];
AAC # let before=book(3,&rows)
AAC # let r=report(&before,Some(&facts(3,4)),None).unwrap()
AAC # assert_eq!(r.get("status").and_then(Json::as_str),Some("identified"))
AAC # assert_eq!(r.get("prediction").and_then(Json::as_str),Some("even"))
AAC # rows.push((4,"odd"))
AAC # let wrong=experiment(&book(3,&rows),Some(&facts(3,4)),None,Some("4")).unwrap()
AAC # let delta=wrong.get("evidence_change").unwrap()
AAC # assert_eq!(delta.get("status").and_then(Json::as_str),Some("falsified"))
AAC # assert_eq!(delta.get("models_without"),Some(&Json::Num(1.0)))
AAC # assert_eq!(delta.get("models_with"),Some(&Json::Num(0.0)))
AAC # assert_eq!(delta.get("eliminated"),Some(&Json::Null))
AAC # assert_eq!(wrong.get("prediction"),Some(&Json::Null))
TTT # end
TTT # end