Beispiel #1
0
 def __init__(self, connection: argo.HasProtocolState,
              goal: cryptoltypes.CryptolJSON, script: ProofScript,
              timeout: Optional[float]) -> None:
     params = {'goal': cryptoltypes.to_cryptol(goal), 'script': script}
     super(Prove, self).__init__('SAW/prove',
                                 params,
                                 connection,
                                 timeout=timeout)
Beispiel #2
0
def prove(goal: cryptoltypes.CryptolJSON,
          proof_script: proofscript.ProofScript) -> ProofResult:
    """Atempts to prove that the expression given as the first argument, `goal`, is
    true for all possible values of free symbolic variables. Uses the proof
    script (potentially specifying an automated prover) provided by the second
    argument.
    """
    conn = __get_designated_connection()
    res = conn.prove(cryptoltypes.to_cryptol(goal),
                     proof_script.to_json()).result()
    pr = ProofResult()
    if res['status'] == 'valid':
        pr.valid = True
    elif res['status'] == 'invalid':
        pr.valid = False
    else:
        raise ValueError("Unknown proof result " + str(res))
    if 'counterexample' in res:
        pr.counterexample = [(arg['name'],
                              cryptol.from_cryptol_arg(arg['value']))
                             for arg in res['counterexample']]
    else:
        pr.counterexample = None
    return pr
Beispiel #3
0
 def to_json(self) -> Any:
     return {'setup value': 'Cryptol', 'expression': cryptoltypes.to_cryptol(self.expression)}
Beispiel #4
0
 def to_json(self) -> Any:
     return cryptoltypes.to_cryptol(self.cryptol_term)
Beispiel #5
0
 def to_json(self) -> JSON:
     return {"server name": self.name,
             "value": cryptoltypes.to_cryptol(self.value)}
Beispiel #6
0
 def to_json(self) -> Any:
     return cryptoltypes.to_cryptol(self.expression)