Atelier des rouesLab FR
Objects/Documentation

verifier25.py

Shared conditionals and checks · verifier25.py

Download ↓
"""Check the profile independently over the reals with optional Z3; also run a rational event check."""
import argparse,json
from fractions import Fraction as F
from itertools import product
from pathlib import Path

def verify(smt=False):
    d=json.loads(Path(__file__).with_name('profil25.json').read_bytes())['profile']
    targets=[list(map(F,row)) for row in d['target']]
    flags=list(product(range(2),repeat=4))
    for row,m,wanted in zip(targets,map(F,d['masses']),map(F,d['errors'])):
        u,v=F(d['u']),F(d['v'])
        image=[m*u,m*(1-u),(1-m)*v,(1-m)*(1-v)]
        assert max(sum(f*(s-t) for f,s,t in zip(mask,image,row)) for mask in flags)==wanted
    assert F(d['value'])==max(map(F,d['errors']))==F(19,100)
    out=dict(events=len(flags),rows=3,upper='19/100')

Read in context

Comments

Comments from both language editions appear here.

The discussion is open for reading. I’ll enable submissions once spam protection is configured.