简体   繁体   中英

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:

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

您可以将其缩短:

start_date <= b and s <=end_date

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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