@@ -2028,6 +2028,8 @@ start is found inside a proof."
2028
2028
maybe-result
2029
2029
inside-proof
2030
2030
proof-start-span-start proof-start-span-end
2031
+ ; ; t if the proof contains state changing commands and must be kept
2032
+ proof-must-be-kept
2031
2033
; ; the current vanilla item
2032
2034
item
2033
2035
; ; the command of the current item
@@ -2061,7 +2063,12 @@ start is found inside a proof."
2061
2063
(line-number-at-pos (span-end (car item))))))
2062
2064
2063
2065
; ; else - no nested proof, but still inside-proof
2064
- (if (string-match proof-script-proof-end-regexp cmd)
2066
+ (if (and (string-match proof-script-proof-end-regexp cmd)
2067
+ (not proof-must-be-kept))
2068
+ ; ; End of opaque proof recognized and we didn't
2069
+ ; ; recognize a state changing command inside the
2070
+ ; ; proof that would prohibit throwing the proof
2071
+ ; ; away.
2065
2072
(let
2066
2073
; ; Reuse the Qed span for the whole proof,
2067
2074
; ; including the faked Admitted command.
@@ -2102,15 +2109,27 @@ start is found inside a proof."
2102
2109
(setq inside-proof nil ))
2103
2110
2104
2111
; ; else - no nested proof, no opaque proof, but still inside
2105
- (if (string-match proof-script-definition-end-regexp cmd)
2112
+ (if (or (string-match proof-script-definition-end-regexp cmd)
2113
+ (and (string-match proof-script-proof-end-regexp cmd)
2114
+ proof-must-be-kept))
2106
2115
; ; A proof ending in Defined or something similar.
2116
+ ; ; Or a proof containing a state changing command
2117
+ ; ; such that the proof-must-be-kept.
2107
2118
; ; Need to keep all commands from the start of the proof.
2108
2119
(progn
2109
2120
(setq result (cons item (nconc maybe-result result)))
2110
2121
(setq maybe-result nil )
2111
2122
(setq inside-proof nil ))
2112
- ; ; normal proof command - maybe it belongs to a
2123
+
2124
+ ; ; else - inside proof, no proof termination recognized
2125
+ ; ; Normal proof command - maybe it belongs to a
2113
2126
; ; Defined, keep it separate, until we know.
2127
+ (when (and proof-script-cmd-prevents-proof-omission
2128
+ (not (eq (span-property (car item) 'type ) 'comment ))
2129
+ (not proof-must-be-kept)
2130
+ (funcall proof-script-cmd-prevents-proof-omission
2131
+ cmd))
2132
+ (setq proof-must-be-kept t ))
2114
2133
(push item maybe-result)))))
2115
2134
2116
2135
; ; else - outside proof
@@ -2121,7 +2140,8 @@ start is found inside a proof."
2121
2140
(push item result)
2122
2141
(setq proof-start-span-start (span-start (car item)))
2123
2142
(setq proof-start-span-end (span-end (car item)))
2124
- (setq inside-proof t ))
2143
+ (setq inside-proof t )
2144
+ (setq proof-must-be-kept nil ))
2125
2145
; ; outside, no proof start - keep it unmodified
2126
2146
(push item result)))
2127
2147
(setq vanillas (cdr vanillas)))
0 commit comments