Skip to content

Commit be91981

Browse files
committed
Some more formula transformation algorithms
new file: src/notebook/math/logic/transformation/dual.py
1 parent 392d6ca commit be91981

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1274
-276
lines changed

notebook.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
\include{text/logical_consequence}
203203
\include{text/boolean_functions}
204204
\include{text/propositional_logic}
205-
\include{text/propositional_normal_forms}
205+
\include{text/propositional_formula_transformations}
206206
\include{text/propositional_axiomatic_derivations}
207207
\include{text/propositional_natural_deduction}
208208
\include{text/propositional_completeness}

packages/math_macros.sty

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
\NewDocumentCommand \boxprod {} {\mathbin \smwhtsquare}
2222
\NewDocumentCommand \anon {s} {\mathbin {\IfBooleanTF {#1} - \smblkcircle}}
2323
\NewDocumentCommand \Anon {s} {\mathbin {\IfBooleanTF {#1} - \mdsmblkcircle}}
24-
\NewDocumentCommand \relcirc {s} {\IfBooleanTF {#1} {\thinspace \circ \thinspace} {\mathrel \circ}}
2524
\NewDocumentCommand \bincirc {s} {\IfBooleanTF {#1} {\thinspace \circ \thinspace} {\mathbin \circ}}
2625
\NewDocumentCommand \binast {s} {\IfBooleanTF {#1} {\thinspace \circ \ast} {\mathbin \ast}}
2726
\NewDocumentCommand \multto {} {\rightrightarrows}

src/notebook/math/combinatorics/ramsey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def ramsey_upper_bound(s: int, t: int, *rest: int) -> int:
2626
def enumerate_edge_coloring_sequences(n: int, r: int) -> Iterable[Collection[int]]:
2727
colors = list(range(r))
2828
m = choose(n, 2)
29-
yield from itertools.product(*([colors] * m))
29+
yield from itertools.product(colors, repeat=m)
3030

3131

3232
def enumerate_complete_graph_coloring(n: int, r: int) -> Iterable[EdgeColoredGraph]:

src/notebook/math/lambda_/curry_howard/conftest.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
@pytest.fixture
88
def ch_logic_dummy_signature() -> FormalLogicSignature:
9-
signature = PropositionalLogicSignature()
10-
11-
for ind in range(ord('α'), ord('ω') + 1):
12-
signature.add_symbol(PropositionalVariable(chr(ind)))
13-
14-
return signature
9+
return PropositionalLogicSignature(
10+
*(PropositionalVariable(chr(i)) for i in range(ord('α'), ord('ω') + 1))
11+
)

src/notebook/math/lambda_/terms/schemas.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class VariablePlaceholder:
1313
def __str__(self) -> str:
1414
return str(self.identifier)
1515

16+
def __repr__(self) -> str:
17+
return f"parse_term_schema('{self}')"
18+
1619

1720
@dataclass(frozen=True)
1821
class TermPlaceholder:
@@ -21,6 +24,9 @@ class TermPlaceholder:
2124
def __str__(self) -> str:
2225
return str(self.identifier)
2326

27+
def __repr__(self) -> str:
28+
return f"parse_term_schema('{self}')"
29+
2430

2531
@dataclass(frozen=True)
2632
class TypedApplicationSchema:
@@ -30,6 +36,9 @@ class TypedApplicationSchema:
3036
def __str__(self) -> str:
3137
return f'({self.left}{self.right})'
3238

39+
def __repr__(self) -> str:
40+
return f"parse_term_schema('{self}')"
41+
3342

3443
@dataclass(frozen=True)
3544
class TypedAbstractionSchema:
@@ -40,5 +49,8 @@ class TypedAbstractionSchema:
4049
def __str__(self) -> str:
4150
return f'({BinderSymbol.LAMBDA}{self.var}:{self.var_type}.{self.body})'
4251

52+
def __repr__(self) -> str:
53+
return f"parse_term_schema('{self}')"
54+
4355

4456
TypedTermSchema = Constant | VariablePlaceholder | TermPlaceholder | TypedApplicationSchema | TypedAbstractionSchema

src/notebook/math/lambda_/terms/terms.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class Constant:
1212
def __str__(self) -> str:
1313
return str(self.name)
1414

15+
def __repr__(self) -> str:
16+
return f"parse_term('{self}')"
17+
1518

1619
@dataclass(frozen=True)
1720
class Variable:
@@ -20,6 +23,9 @@ class Variable:
2023
def __str__(self) -> str:
2124
return str(self.identifier)
2225

26+
def __repr__(self) -> str:
27+
return f"parse_term('{self}')"
28+
2329

2430
@dataclass(frozen=True)
2531
class UntypedApplication:
@@ -29,6 +35,9 @@ class UntypedApplication:
2935
def __str__(self) -> str:
3036
return f'({self.left}{self.right})'
3137

38+
def __repr__(self) -> str:
39+
return f"parse_term('{self}')"
40+
3241

3342
@dataclass(frozen=True)
3443
class TypedApplication:
@@ -38,6 +47,9 @@ class TypedApplication:
3847
def __str__(self) -> str:
3948
return f'({self.left}{self.right})'
4049

50+
def __repr__(self) -> str:
51+
return f"parse_term('{self}')"
52+
4153

4254
@dataclass(frozen=True)
4355
class UntypedAbstraction:
@@ -47,6 +59,9 @@ class UntypedAbstraction:
4759
def __str__(self) -> str:
4860
return f'({BinderSymbol.LAMBDA}{self.var}.{self.body})'
4961

62+
def __repr__(self) -> str:
63+
return f"parse_term('{self}')"
64+
5065

5166
@dataclass(frozen=True)
5267
class TypedAbstraction:
@@ -57,6 +72,9 @@ class TypedAbstraction:
5772
def __str__(self) -> str:
5873
return f'({BinderSymbol.LAMBDA}{self.var}:{self.var_type}.{self.body})'
5974

75+
def __repr__(self) -> str:
76+
return f"parse_term('{self}')"
77+
6078

6179
UntypedTerm = Constant | Variable | UntypedApplication | UntypedAbstraction
6280
TypedTerm = Constant | Variable | TypedApplication | TypedAbstraction

src/notebook/math/lambda_/types/schemas.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class TypePlaceholder:
1212
def __str__(self) -> str:
1313
return str(self.identifier)
1414

15+
def __repr__(self) -> str:
16+
return f"parse_type_schema('{self}')"
17+
1518

1619
@dataclass(frozen=True)
1720
class SimpleConnectiveTypeSchema:
@@ -22,5 +25,8 @@ class SimpleConnectiveTypeSchema:
2225
def __str__(self) -> str:
2326
return f'({self.left} {self.conn} {self.right})'
2427

28+
def __repr__(self) -> str:
29+
return f"parse_type_schema('{self}')"
30+
2531

2632
SimpleTypeSchema = BaseType | TypePlaceholder | SimpleConnectiveTypeSchema

src/notebook/math/lambda_/types/types.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class BaseType:
1212
def __str__(self) -> str:
1313
return str(self.name)
1414

15+
def __repr__(self) -> str:
16+
return f"parse_type('{self}')"
17+
1518

1619
@dataclass(frozen=True)
1720
class TypeVariable:
@@ -20,6 +23,9 @@ class TypeVariable:
2023
def __str__(self) -> str:
2124
return str(self.identifier)
2225

26+
def __repr__(self) -> str:
27+
return f"parse_type('{self}')"
28+
2329

2430
@dataclass(frozen=True)
2531
class SimpleConnectiveType:
@@ -30,6 +36,9 @@ class SimpleConnectiveType:
3036
def __str__(self) -> str:
3137
return f'({self.left} {self.conn} {self.right})'
3238

39+
def __repr__(self) -> str:
40+
return f"parse_type('{self}')"
41+
3342

3443
SimpleType = BaseType | TypeVariable | SimpleConnectiveType
3544

src/notebook/math/logic/deduction/test_proof_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
parse_formula_placeholder,
1212
parse_formula_with_substitution,
1313
parse_marker,
14-
parse_propositional_formula,
1514
parse_term_substitution_spec,
1615
parse_variable,
1716
)
17+
from ..propositional import parse_propositional_formula
1818
from ..signature import FormalLogicSignature
1919
from .exceptions import RuleApplicationError
2020
from .proof_tree import AssumptionTree, ProofTree, RuleApplicationPremise, apply, assume, premise

src/notebook/math/logic/derivation/test_axiomatic_derivation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from textwrap import dedent
33

44
from ....support.pytest import pytest_parametrize_kwargs, pytest_parametrize_lists
5-
from ..parsing import parse_propositional_formula
5+
from ..propositional import parse_propositional_formula
66
from .axiomatic_derivation import (
77
AxiomaticDerivation,
88
are_derivations_equivalent,

0 commit comments

Comments
 (0)