commit
8b09bba2c4
@ -0,0 +1,163 @@
|
||||
### Generated by gibo (https://github.com/simonwhitaker/gibo)
|
||||
### https://raw.github.com/github/gitignore/4488915eec0b3a45b5c63ead28f286819c0917de/Python.gitignore
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
@ -0,0 +1,102 @@
|
||||
PEOPLE = [
|
||||
{
|
||||
"name": "Tait Hoyem",
|
||||
"has_moodle_account": True,
|
||||
"has_taken_a_calculus_class": False,
|
||||
"is_student": True,
|
||||
"is_cs_student": True,
|
||||
"is_ee_student": False,
|
||||
"is_cpsc1820_student": True,
|
||||
"has_visited_usa": True,
|
||||
"is_smart": True,
|
||||
"age": 24,
|
||||
"enjoys_cpsc1820": False,
|
||||
},
|
||||
{
|
||||
"name": "Jaspreet Kaur",
|
||||
"has_moodle_account": True,
|
||||
"has_taken_a_calculus_class": True,
|
||||
"has_visited_usa": True,
|
||||
"is_student": False,
|
||||
"is_cs_student": False,
|
||||
"is_ee_student": False,
|
||||
"is_cpsc1820_student": False,
|
||||
"is_smart": True,
|
||||
"age": -1,
|
||||
"enjoys_cpsc1820": True,
|
||||
},
|
||||
{
|
||||
"name": "Ibrahim Abdulahi",
|
||||
"has_moodle_account": True,
|
||||
"has_taken_a_calculus_class": False,
|
||||
"has_visited_usa": True,
|
||||
"is_student": False,
|
||||
"is_cs_student": False,
|
||||
"is_ee_student": False,
|
||||
"is_cpsc1820_student": False,
|
||||
"is_smart": True,
|
||||
"age": -1,
|
||||
"enjoys_cpsc1820": False,
|
||||
},
|
||||
{
|
||||
"name": "Issac Newton",
|
||||
"has_moodle_account": True,
|
||||
"has_taken_a_calculus_class": False,
|
||||
"has_visited_usa": True,
|
||||
"is_student": False,
|
||||
"is_cs_student": False,
|
||||
"is_ee_student": False,
|
||||
"is_smart": True,
|
||||
"is_cpsc1820_student": False,
|
||||
"age": 482,
|
||||
"enjoys_cpsc1820": True,
|
||||
},
|
||||
{
|
||||
"name": "Albert Enstein",
|
||||
"has_taken_a_calculus_class": True,
|
||||
"has_moodle_account": True,
|
||||
"has_visited_usa": False,
|
||||
"is_student": False,
|
||||
"is_cs_student": False,
|
||||
"is_ee_student": False,
|
||||
"is_smart": True,
|
||||
"is_cpsc1820_student": False,
|
||||
"age": 125,
|
||||
"enjoys_cpsc1820": True,
|
||||
},
|
||||
{
|
||||
"name": "John James",
|
||||
"has_taken_a_calculus_class": False,
|
||||
"has_moodle_account": True,
|
||||
"has_visited_usa": False,
|
||||
"is_student": True,
|
||||
"is_smart": True,
|
||||
"is_cs_student": True,
|
||||
"is_ee_student": False,
|
||||
"is_cpsc1820_student": True,
|
||||
"age": 29,
|
||||
"enjoys_cpsc1820": False,
|
||||
},
|
||||
{
|
||||
"name": "Anthony Shih",
|
||||
"has_taken_a_calculus_class": False,
|
||||
"has_moodle_account": True,
|
||||
"has_visited_usa": False,
|
||||
"is_student": False,
|
||||
"is_cs_student": False,
|
||||
"is_ee_student": True,
|
||||
"is_cpsc1820_student": True,
|
||||
"is_smart": False,
|
||||
"age": 19,
|
||||
"enjoys_cpsc1820": False,
|
||||
},
|
||||
]
|
||||
|
||||
def is_student(x):
|
||||
return x["is_student"]
|
||||
|
||||
def is_1820_student(x):
|
||||
return x["is_cpsc1820_student"]
|
||||
|
||||
STUDENTS = list(filter(is_student, PEOPLE))
|
||||
CPSC1820_STUDENTS = list(filter(is_1820_student, PEOPLE))
|
@ -0,0 +1,51 @@
|
||||
from utils import implies
|
||||
|
||||
FRUITS = [
|
||||
{
|
||||
"name": "Banana",
|
||||
"tropical": True,
|
||||
"delicious": True,
|
||||
"at_walmart": True,
|
||||
},
|
||||
{
|
||||
"name": "Dragon Fruit",
|
||||
"delicious": True,
|
||||
"at_walmart": False,
|
||||
"tropical": True,
|
||||
},
|
||||
{
|
||||
"name": "Orange",
|
||||
"delicious": False,
|
||||
"at_walmart": True,
|
||||
"tropical": True,
|
||||
},
|
||||
{
|
||||
"name": "Mango",
|
||||
"delicious": True,
|
||||
"at_walmart": False,
|
||||
"tropical": True,
|
||||
},
|
||||
{
|
||||
"name": "Watermelon",
|
||||
"delicious": True,
|
||||
"at_walmart": True,
|
||||
"tropical": True,
|
||||
},
|
||||
]
|
||||
|
||||
def T(x):
|
||||
return x["tropical"]
|
||||
|
||||
def D(x):
|
||||
return x["delicious"]
|
||||
|
||||
def W(x):
|
||||
return x["at_walmart"]
|
||||
|
||||
U = FRUITS
|
||||
|
||||
# If a tropical fruit is delicious then it is available in Walmart.
|
||||
# ∀x [(T(x) ∧ D(x)) → W(x)]
|
||||
prop = all(map(lambda x: implies(T(x) and D(x), W(x)), U))
|
||||
print("If a tropical fruit is delicious then it is available in Walmart.")
|
||||
print("∀x [(T(x) ∧ D(x)) → W(x)]: ", prop)
|
@ -0,0 +1,59 @@
|
||||
from data import STUDENTS, PEOPLE
|
||||
|
||||
def R(x):
|
||||
return x["has_moodle_account"]
|
||||
|
||||
def R2(x):
|
||||
return x["has_taken_a_calculus_class"]
|
||||
|
||||
def R3(x):
|
||||
return not R2(x)
|
||||
|
||||
def M(x):
|
||||
return x["has_visited_usa"]
|
||||
|
||||
def S(x):
|
||||
return x["is_student"]
|
||||
|
||||
print("Where R(x) is a student who has a mododle account")
|
||||
|
||||
# ∀x R(x)
|
||||
prop1 = all(map(R, STUDENTS))
|
||||
print("∀x R(x): ", end="")
|
||||
print(prop1)
|
||||
|
||||
# ∃x R(x)
|
||||
prop2 = any(map(R, STUDENTS))
|
||||
print("∃x R(x): ", end="")
|
||||
print(prop2)
|
||||
|
||||
print()
|
||||
print("Where R(x) is a student that has taken a calculsu course")
|
||||
|
||||
# ∀x P(x)
|
||||
prop3 = all(map(R2, STUDENTS))
|
||||
print("∀x P(x): ", end="")
|
||||
print(prop3)
|
||||
|
||||
# ∃x ¬P(x)
|
||||
props4 = any(map(R3, STUDENTS))
|
||||
print("∃x ¬P(x): ", end="")
|
||||
print(props4)
|
||||
|
||||
print()
|
||||
print("Where M(x) is somebody who has been to the USA")
|
||||
print("And U = {all students in CPSC 1820")
|
||||
|
||||
# Assume, U = {all students in CPSC 1820}
|
||||
# ∃x M(x)
|
||||
|
||||
props5 = any(map(M, STUDENTS))
|
||||
print("∃x M(x): ", end="")
|
||||
print(props5)
|
||||
|
||||
# Assume, U = {all people}
|
||||
# ∃x [S(x) ∧ M(x)]
|
||||
props6 = any(map(lambda x: M(x) and S(x), PEOPLE))
|
||||
print("∃x [S(x) ∧ M(x)]: ", end="")
|
||||
print(props6)
|
||||
|
@ -0,0 +1,2 @@
|
||||
def implies(x,y):
|
||||
return not (x and not y)
|
Loading…
Reference in new issue