Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change names of CoqChangeProofs to ProofChanges #39

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions coqpyt/coq/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class CoqDeleteStep(CoqChange):
step_index: int


class CoqChangeProof:
class ProofChange:
pass


@dataclass
class CoqProofAppend(CoqChangeProof):
class ProofAppend(ProofChange):
step_text: str


@dataclass
class CoqProofPop(CoqChangeProof):
class ProofPop(ProofChange):
pass
10 changes: 5 additions & 5 deletions coqpyt/coq/proof_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,27 +877,27 @@ def pop_step(self, proof: ProofTerm):
step_index = self.__find_step_index(proof.ast.range)
self.delete_step(step_index + len(proof.steps))

def change_proof(self, proof: ProofTerm, proof_changes: List[CoqChangeProof]):
def change_proof(self, proof: ProofTerm, proof_changes: List[ProofChange]):
"""Changes the steps of a proof transactionally.
If an exception is thrown the file will not be changed.

Args:
changes (List[CoqChangeProof]): The changes to be applied to the proof.
changes (List[ProofChange]): The changes to be applied to the proof.

Raises:
InvalidFileException: If the file being changed is not valid.
InvalidChangeException: If the file is invalid after applying the changes.
NotImplementedError: If the changes contain an unknown CoqChangeProof.
NotImplementedError: If the changes contain an unknown ProofChange.
"""
step_index = self.__find_step_index(proof.ast.range)
changes: List[CoqChange] = []
offset = len(proof.steps)

for change in proof_changes:
if isinstance(change, CoqProofPop):
if isinstance(change, ProofPop):
changes.append(CoqDeleteStep(step_index + offset))
offset -= 1
elif isinstance(change, CoqProofAppend):
elif isinstance(change, ProofAppend):
changes.append(CoqAddStep(change.step_text, step_index + offset))
offset += 1

Expand Down
4 changes: 1 addition & 3 deletions coqpyt/tests/proof_file/test_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ def test_proof_changes(self):
== "Theorem mult_0_plus : ∀ n m : nat, S n * m = 0 + (S n * m)."
)

self.proof_file.change_proof(
unproven[0], [CoqProofPop(), CoqProofAppend("\nQed.")]
)
self.proof_file.change_proof(unproven[0], [ProofPop(), ProofAppend("\nQed.")])
assert self.proof_file.unproven_proofs == []


Expand Down
Loading