Skip to content

Commit

Permalink
interpretation
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddoret committed Dec 7, 2024
1 parent 6d7d61a commit 8d2f158
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
18 changes: 9 additions & 9 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions src/punctilious/interpretation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@
| formula_expression INFIX_CONNECTOR formula_expression -> parse_infix_formula
| PREFIX_CONNECTOR ATOMIC_CONNECTOR -> parse_prefix_formula
| ATOMIC_CONNECTOR -> parse_atomic_formula
| "(" FUNCTION_CONNECTOR "(" function_formula_arguments ")" ")" -> parse_function_formula
| "(" formula_expression INFIX_CONNECTOR formula_expression ")" -> parse_infix_formula
| "(" PREFIX_CONNECTOR ATOMIC_CONNECTOR ")" -> parse_prefix_formula
| "(" ATOMIC_CONNECTOR ")" -> parse_atomic_formula
function_formula_arguments : formula_expression ("," formula_expression)* -> parse_function_formula_arguments
function_formula_arguments . 20 : formula_expression ("," formula_expression)* -> parse_function_formula_arguments
parenthesized_formula_expression .10 : "(" formula_expression ")"
FUNCTION_CONNECTOR . 1 : "is-a-proposition" | "is-a-natural-number"
INFIX_CONNECTOR . 2 : "and" | "et" | "∧" | "^"
PREFIX_CONNECTOR . 3 : "not" | "non" | "¬" | "~"
ATOMIC_CONNECTOR . 4 : "P" | "Q" | "R"
FUNCTION_CONNECTOR . 4 : "not" | "non" | "¬" | "~" | "is-a-proposition" | "is-a-natural-number"
INFIX_CONNECTOR . 3 : "and" | "et" | "∧" | "^" | "or"
PREFIX_CONNECTOR . 2 : "not" | "non" | "¬" | "~"
ATOMIC_CONNECTOR . 1 : "P" | "Q" | "R"
%import common.WS
%ignore WS
Expand Down Expand Up @@ -100,4 +105,12 @@ def interpret_formula(input_string: str) -> Formula:
formula = interpret_formula(input_string)
input_string = "not P"
formula = interpret_formula(input_string)
input_string = "(P and Q)"
formula = interpret_formula(input_string)
input_string = "(P and Q) and (Q and P)"
formula = interpret_formula(input_string)
input_string = "not(not P)"
formula = interpret_formula(input_string)
input_string = "not(not (is-a-proposition(P) and Q) and (Q and P))"
formula = interpret_formula(input_string)
pass

0 comments on commit 8d2f158

Please sign in to comment.