#!/usr/bin/env python3 """Independent regression/adversarial tests; executable without pytest.""" from pathlib import Path from itertools import product from collections import deque import copy,hashlib,json,random,time from engine import Improver,Rule,Guard,family,cold_search,ref_eval,shortlex from verifier import verify,evaluate ROOT=Path(__file__).resolve().parent def rehash(p): d=p['guard'];d['sha256']=hashlib.sha256(json.dumps([d['transition'],d['reject']],separators=(',',':')).encode()).hexdigest() def normalize(w,laws): while True: for law in laws: for i in range(len(w)-len(law.lhs)+1): if w[i:i+len(law.lhs)]==law.lhs: new=w[:i]+law.rhs+w[i+len(law.lhs):] assert shortlex(new)