简体   繁体   English

如何用not and or简化布尔表达式?

[英]How to simplify boolean expression with not and or?

I have the following boolean expression: 我有以下布尔表达式:

not (start_date > b or s > end_date)

how to simplify it? 如何简化呢?

def is_date_in_items(end_date, start_date, items):
    b, s = _get_biggest_and_smallest_date(items)
    return not (start_date > b or s > end_date)
not (start_date > b or s > end_date)

// is equivalent to 
not(start_date > b) and not(s > end_date)

// which is equivalent to 
start_data <= b and s <= end_date

This comes from De Morgan's Laws which states that: 这来自De Morgan的法律 ,该法律指出:

¬(P OR Q) <=> (¬P) AND (¬Q) 

您可以将其缩短:

start_date <= b and s <=end_date

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM