Rule

Define the Rule as used in Newclid.

Rules represent theorems of geometry that are considered as axioms in the proof.

class RuleConstruction(**data)

Bases: BaseModel

A construction in a rule.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

name: str

Name of the construction.

variables: tuple[VarName, ...]

Input variable names.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class RuleApplication(**data)

Bases: BaseModel

A rule application.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

predicate: Predicate

The predicate justified by the rule.

rule: Rule

The rule applied.

premises: tuple[Predicate, ...]

The premises of the rule.

dependency_type: Literal[JustificationType.RULE_APPLICATION]
canonicalize()
Return type:

Self

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Rule(**data)

Bases: BaseModel

Deduction rule.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

id: str

Unique permanent identifier for the rule.

description: str

Descriptive name for the rule.

premises_txt: tuple[str, ...]

Tuple of predicates representing the hypothesis of the rule.

conclusions_txt: tuple[str, ...]

Tuple of predicates representing the conclusions of the rule.

allow_point_repetition: bool

Whether the same point can correspond to different variables in the rule presentation.

property premises: list[RuleConstruction]
property conclusions: list[RuleConstruction]
property fullname: str
property variables: list[VarName]
rules_from_file(file_path)

Load deduction rule from a file.

Return type:

list[Rule]

rules_from_txt(text)

Load deduction rule from a txt object.

Return type:

list[Rule]