Skip to content
Snippets Groups Projects
Commit a76336d9 authored by Jannik Schleicher's avatar Jannik Schleicher
Browse files

init

parents
Branches master
No related tags found
No related merge requests found
FROM python:3.8-slim
# We copy just the requirements.txt first to leverage Docker cache
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r requirements.txt
COPY . /app
ENTRYPOINT [ "python" ]
CMD [ "cheat.py" ]
\ No newline at end of file
File added
cheat.py 0 → 100644
from flask import Flask
app = Flask(__name__)
import re, string
sanatize_pattern = re.compile('[\W]+')
sanatize_pattern.sub('', string.printable)
@app.route("/")
def index():
return "Logik Cheatsheet"
import content_mapper as cm
@app.route("/<query>")
def query(query):
topic = sanatize_pattern.sub('', query)
for kws, route in cm.keywords:
if topic in kws:
return route(topic)
return "not found\n"
if __name__ == "__main__":
app.run(host='0.0.0.0')
\ No newline at end of file
col_stack = []
def format(text: str, fmt: str) -> str:
last_col = "\u001b[0m" if len(col_stack) == 0 else col_stack[:-1]
col_stack.append(f"\u001b[{fmt}m")
value = f"\u001b[{fmt}m{text}{last_col}"
col_stack.pop()
return value
def head(text: str) -> str:
return format(text, "31;1;4")
def f(text: str) -> str:
return format(text, "32;1")
def infix_notation(query):
return f"""
{head("Präfix-Notation")}
Operatoren werden zwischen die Operanden gesetzt
(A + B)
(A v B)
"""
def praefix_notation(query):
return f"""
{head("Präfix-Notation")}
Operatoren werden vor die Operanden gesetzt
+ A B
v A B
"""
def aussage(query):
return f"""
{head("Aussagenlogik")}
- Prinzip der Zweiwertigkeit: Jede Aussage ist wahr oder falsch
- Prinzip vom ausgeschlossenen Widerspruch: Es gibt keine Aussage, die sowohl wahr als auch falsch ist.
→ Jede Aussage ist entweder wahr oder falsch.
"""
def signatur(q):
return f"""
{head("Signatur (Aussagenlogik)")}
abzählbare Menge von Aussagensymbolen
AS = {{ P0, ..., Pn }}
"""
def negation(q):
return f"""
{head("Negation (Junktor)")}
Beispiel: ¬A
Gesprochen: „nicht A“
A | ¬A
--------
W | F
F | W
"""
def implikation(q):
return f"""
{head("Implikation (Junktor)")}
Beispiel: A → B
Gesprochen: „wenn A dann B“
Äquivalent zu (¬A ∨ B)
A | B | A → B
--------------
W | W | W
W | F | F
F | W | W
F | F | W
"""
def disjunktion(q):
return f"""
{head("Disjunktion (Junktor)")}
Beispiel: A ∨ B
Gesprochen: „A oder B“
A | B | A ∧ B
--------------
W | W | W
W | F | W
F | W | W
F | F | F
"""
def konjunktion(q):
return f"""
{head("Konjunktion (Junktor)")}
Beispiel: A ∧ B
Gesprochen: „A und B“
A | B | A ∧ B
--------------
W | W | W
W | F | F
F | W | F
F | F | F
"""
def formel(q):
return f"""
{head("Formel (Aussagenlogik)")}
Formeln werden durch Kombination von Aussagensymbolen und Junktoren gebildet.
Die Menge aller aussagenlogischen Formeln über AS ist induktiv wie folgt definiert:
* 1. für jedes P ∈ AS ist P eine Formel
* wenn 𝜑 und ψ Formeln sind, dann sind auch
2. ¬𝜑
3. (𝜑 ∧ ψ)
4. (𝜑 ∨ ψ)
5. (𝜑 → ψ)
6. (𝜑 ↔ ψ)
Formeln.
Wir verwenden griechische Buchstaben (𝜑, ψ, ...) zur
Benennung von Formeln.
"""
def aussagensymbol(q):
return f"""
{head("Aussagensymbol (Aussagenlogik)")}
Atomare Formeln, die einen Wahrheitswert darstellen
AS = {f("{ A, B }")}
𝜑 = A ∧ B
.-----^-----^
'- Aussagensymbol
"""
keywords = [
(["infix", "Infixnotation", "Algebraische Notation"], infix_notation),
(["prefix", "präfix", "präfixnotation"], praefix_notation),
(["aussage"], aussage),
(["signatur"], signatur),
(["negation"], negation),
(["implikation"], implikation),
(["konjunktion"], konjunktion),
(["disjunktion"], disjunktion),
(["aussagensymbol"], aussagensymbol)
]
\ No newline at end of file
flask==2.0.1
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment