From 79b61f28a451c2477e9d92eec4df29b3cd92ad8e Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Tue, 1 Oct 2024 18:45:00 -0700 Subject: [PATCH 1/3] Change Bool is_true and is_false implementations to avoid backends --- claripy/ast/bool.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/claripy/ast/bool.py b/claripy/ast/bool.py index 6d2aafbfc..e492c9f57 100644 --- a/claripy/ast/bool.py +++ b/claripy/ast/bool.py @@ -1,14 +1,13 @@ from __future__ import annotations import logging -from contextlib import suppress from functools import lru_cache from typing import TYPE_CHECKING, overload import claripy from claripy import operations from claripy.ast.base import ASTCacheKey, Base, _make_name -from claripy.errors import BackendError, ClaripyTypeError +from claripy.errors import ClaripyTypeError from .bits import Bits @@ -163,17 +162,17 @@ def If(cond, true_value, false_value): Bool.__ror__ = Or -def is_true(e, exact=None): # pylint:disable=unused-argument - with suppress(BackendError): - return claripy.backends.concrete.is_true(e) +def is_true(e): + if claripy.simplify(e) is True: + return True log.debug("Unable to tell the truth-value of this expression") return False -def is_false(e, exact=None): # pylint:disable=unused-argument - with suppress(BackendError): - return claripy.backends.concrete.is_false(e) +def is_false(e): + if claripy.simplify(e) is False: + return True log.debug("Unable to tell the truth-value of this expression") return False From eddf1abef1b6b92153f014c78fb91aacad2488b8 Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Wed, 2 Oct 2024 11:16:16 -0700 Subject: [PATCH 2/3] Use the right true and false --- claripy/ast/bool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/claripy/ast/bool.py b/claripy/ast/bool.py index e492c9f57..51b14cd7b 100644 --- a/claripy/ast/bool.py +++ b/claripy/ast/bool.py @@ -163,7 +163,7 @@ def If(cond, true_value, false_value): def is_true(e): - if claripy.simplify(e) is True: + if claripy.simplify(e) is true(): return True log.debug("Unable to tell the truth-value of this expression") @@ -171,7 +171,7 @@ def is_true(e): def is_false(e): - if claripy.simplify(e) is False: + if claripy.simplify(e) is false(): return True log.debug("Unable to tell the truth-value of this expression") From d358a92b905eae163fc9d3671946392305da5165 Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Wed, 2 Oct 2024 12:16:23 -0700 Subject: [PATCH 3/3] Allow bool types in is_true and is_false --- claripy/ast/bool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/claripy/ast/bool.py b/claripy/ast/bool.py index 51b14cd7b..65657865c 100644 --- a/claripy/ast/bool.py +++ b/claripy/ast/bool.py @@ -163,7 +163,7 @@ def If(cond, true_value, false_value): def is_true(e): - if claripy.simplify(e) is true(): + if e is True or (isinstance(e, Base) and claripy.simplify(e) is true()): return True log.debug("Unable to tell the truth-value of this expression") @@ -171,7 +171,7 @@ def is_true(e): def is_false(e): - if claripy.simplify(e) is false(): + if e is False or (isinstance(e, Base) and claripy.simplify(e) is false()): return True log.debug("Unable to tell the truth-value of this expression")