Skip to content

Instantly share code, notes, and snippets.

@ruoyu0088
Created June 14, 2017 22:36
Show Gist options
  • Save ruoyu0088/35734e8582183a39b850e6ea0cd087d4 to your computer and use it in GitHub Desktop.
Save ruoyu0088/35734e8582183a39b850e6ea0cd087d4 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from sympy import *"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"A, B, C, D, S = symbols(\"A B C D S\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"And(Or(A, B, C, Not(S)), Or(A, B, Not(C), S), Or(A, C, Not(B), S), Or(A, Not(B), Not(C), Not(S)), Or(B, C, Not(A), S), Or(B, Not(A), Not(C), Not(S)), Or(C, Not(A), Not(B), Not(S)), Or(Not(A), Not(B), Not(C), S))"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"to_cnf(Equivalent(Xor(A, B, C), S), simplify=True)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"And(Or(A, B, Not(D)), Or(A, C, Not(D)), Or(B, C, Not(D)), Or(D, Not(A), Not(B)), Or(D, Not(A), Not(C)), Or(D, Not(B), Not(C)))"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"to_cnf(Equivalent(Or(And(A, B), And(B, C), And(A, C)), D), simplify=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment