Skip to content

Commit 24cddb4

Browse files
committed
wip on gfp strategy for nu, base case for ltl ind rule goes through
1 parent c866c11 commit 24cddb4

File tree

6 files changed

+42
-3
lines changed

6 files changed

+42
-3
lines changed

prover/lang/kore-lang.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ only in this scenario*.
163163
| "\\forall" "{" Patterns "}" Pattern [klabel(forall)]
164164
165165
| "\\mu" SetVariable "." Pattern [klabel(mu)]
166+
| "\\nu" SetVariable "." Pattern [klabel(nu)]
166167
/* Sugar for \iff, \mu and application */
167168
| "\\iff-lfp" "(" Pattern "," Pattern ")" [klabel(ifflfp)]
168169
@@ -354,6 +355,7 @@ module KORE-HELPERS
354355
requires getReturnSort(P) =/=K S
355356
356357
rule getReturnSort(\mu _ . Phi) => getReturnSort(Phi)
358+
rule getReturnSort(\nu _ . Phi) => getReturnSort(Phi)
357359
rule getReturnSort(\or(P, Ps)) => unionSort(getReturnSort(P), getReturnSort(\or(Ps)))
358360
rule getReturnSort(\or(.Patterns)) => BottomSort
359361
rule getReturnSort(\and(P, Ps)) => intersectSort(getReturnSort(P), getReturnSort(\and(Ps)))
@@ -604,6 +606,8 @@ where the term being unfolded has been replace by `#hole`.
604606
rule subst(X:Variable,Y:Variable,V) => X requires X =/=K Y
605607
rule subst(X:SetVariable,Y:SetVariable,V) => X requires X =/=K Y
606608
rule subst(X:Variable,P:Pattern, V) => X requires notBool(isVariable(P) orBool isVariableName(P))
609+
rule subst(X:SetVariable,P:Pattern, V) => X
610+
requires notBool(isSetVariable(P))
607611
rule subst(I:Int, X, V) => I
608612
rule subst(\top(),_,_)=> \top()
609613
rule subst(\bottom(),_,_) => \bottom()
@@ -680,6 +684,7 @@ Alpha renaming: Rename all bound variables. Free variables are left unchanged.
680684
rule alphaRename(\exists { Fs:Patterns } P:Pattern)
681685
=> #fun(RENAMING => \exists { Fs[RENAMING] } alphaRename(substMap(P,RENAMING))) ( makeFreshSubstitution(Fs) )
682686
rule alphaRename(\mu X . P:Pattern) => \mu !X . alphaRename(subst(P, X, !X))
687+
rule alphaRename(\nu X . P:Pattern) => \nu !X . alphaRename(subst(P, X, !X))
683688
rule alphaRename(\equals(L, R)) => \equals(alphaRename(L), alphaRename(R))
684689
rule alphaRename(\not(Ps)) => \not(alphaRename(Ps))
685690
rule alphaRename(\functionalPattern(Ps)) => \functionalPattern(alphaRename(Ps))
@@ -753,12 +758,14 @@ single symbol applied to multiple arguments.
753758
rule #nnf(S:Symbol(Args)) => S(#nnfPs(Args))
754759
rule #nnf( \or(Ps)) => \or(#nnfPs(Ps))
755760
rule #nnf(\and(Ps)) => \and(#nnfPs(Ps))
761+
rule #nnf(\implies(L, R)) => #nnf(\or(\not(L), R))
756762
757763
rule #nnf(\not(P)) => \not(P) requires isDnfAtom(P)
758764
rule #nnf(\not(S:Symbol(Args))) => \not(S(#nnfPs(Args)))
759765
rule #nnf(\not( \or(Ps))) => \and(#nnfPs(#not(Ps)))
760766
rule #nnf(\not(\and(Ps))) => \or(#nnfPs(#not(Ps)))
761767
rule #nnf(\not(\not(P))) => #nnf(P)
768+
rule #nnf(\not(\implies(L, R))) => #nnf(\not(\or(\not(L), R)))
762769
763770
syntax Bool ::= isDnfAtom(Pattern) [function]
764771
rule isDnfAtom(V:Variable) => true
@@ -768,9 +775,11 @@ single symbol applied to multiple arguments.
768775
rule isDnfAtom(\exists{Vs}_) => true
769776
rule isDnfAtom(\forall{Vs}_) => true
770777
rule isDnfAtom(\mu X . _) => true
778+
rule isDnfAtom(\nu X . _) => true
771779
rule isDnfAtom(implicationContext(_, _)) => true
772780
rule isDnfAtom(\and(_)) => false
773781
rule isDnfAtom(\or(_)) => false
782+
rule isDnfAtom(\implies(_, _)) => false
774783
rule isDnfAtom(S:Symbol(ARGS)) => false
775784
rule isDnfAtom(\not(P)) => false
776785
```

prover/prover.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module STRATEGIES-EXPORTED-SYNTAX
5656
| "right-unfold" "(" "symbols" ":" Patterns "," "bound" ":" Int ")"
5757
| "kt" | "kt" "#" KTFilter
5858
| "kt-unf" | "kt-unf" "#" KTFilter
59-
| "kt-gfp" | "kt-gfp" "#" KTFilter
59+
| "gfp"
6060
| "kt-solve-implications" "(" Strategy ")"
6161
| "instantiate-universals-with-ground-terms"
6262
| "instantiate-separation-logic-axioms" | "pto-is-injective"

prover/strategies/core.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module PROVER-CORE-SYNTAX
2626
| Strategy "&" Strategy [right, format(%1%n%2 %3)]
2727
| Strategy "|" Strategy [right, format(%1%n%2 %3)]
2828
syntax Strategy ::= "or-split" | "and-split" | "or-split-rhs" | "and-split-rhs"
29-
syntax Strategy ::= "rhs-top"
29+
syntax Strategy ::= "rhs-top" | "contradiction"
3030
syntax Strategy ::= "prune" "(" Patterns ")"
3131
3232
syntax Strategy ::= Strategy "{" Int "}"
@@ -294,6 +294,14 @@ Internal strategy used to implement `or-split` and `and-split`.
294294
<k> rhs-top => success ... </k>
295295
```
296296

297+
`contradiction` evaluates to success if the second clause is the negation of the first
298+
clause in the LHS conjunction
299+
300+
```k
301+
rule <claim> \implies(\and(P, \not(P), REST), RHS) </claim>
302+
<k> contradiction => success ... </k>
303+
```
304+
297305
If-then-else-fi strategy is useful for implementing other strategies:
298306

299307
```k

prover/strategies/knaster-tarski.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ for guessing an instantiation of the inductive hypothesis.
249249
</k>
250250
rule <k> kt-subst(.Patterns, ARGs) => noop ... </k>
251251
252+
// TODO: combine with other kt-unfold rules
253+
rule <claim> \implies(LHS, \nu X . P)
254+
=> \implies(LHS, subst(P, X, alphaRename(LHS)))
255+
</claim>
256+
<k> gfp => noop ... </k>
257+
252258
// unfolded fixed point, HEAD, LRP variables, RHS
253259
syntax Pattern ::= substituteBRPs(Pattern, Symbol, Patterns, Pattern) [function]
254260
rule substituteBRPs(P:Int, RP, Vs, RHS) => P

prover/strategies/matching.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ Recurse over assoc-only constructors (including `pto`):
206206
, rest: REST
207207
)
208208
209+
// Both term and pattern are a nu:
210+
// Recurse over pattern with same fresh variable for each nu term
211+
rule #matchAssoc( terms: (\nu X . T), Ts
212+
=> subst(T, X, !F:SetVariable), Ts
213+
, pattern: (\nu Y . P), Ps
214+
=> subst(P, Y, !F), Ps
215+
, variables: Vs
216+
, subst: SUBST
217+
, rest: REST
218+
)
219+
209220
// ground variable: identical
210221
rule #matchAssoc( terms: P:Variable, Ts => Ts
211222
, pattern: P, Ps => Ps

prover/strategies/unfolding.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module STRATEGY-UNFOLDING
1313
<declaration> axiom _: \forall { Vs } \iff-lfp(S(Vs), DEF) </declaration>
1414
requires getFreeVariables(DEF) -Patterns Vs =/=K .Patterns
1515
rule unfold(\mu X . P) => subst(P, X, alphaRename(\mu X . P))
16+
rule unfold(\nu X . P) => subst(P, X, alphaRename(\nu X . P))
1617
1718
syntax SymbolDeclaration ::= getSymbolDeclaration(Symbol) [function]
1819
rule [[ getSymbolDeclaration(S) => DECL ]]
@@ -33,6 +34,8 @@ module STRATEGY-UNFOLDING
3334
requires isUnfoldable(R)
3435
rule getUnfoldables(\mu X . P, REST)
3536
=> \mu X . P, getUnfoldables(REST)
37+
rule getUnfoldables(\nu X . P, REST)
38+
=> \nu X . P, getUnfoldables(REST)
3639
rule getUnfoldables(S:Symbol, REST)
3740
=> getUnfoldables(REST)
3841
requires notBool isUnfoldable(S)
@@ -44,6 +47,8 @@ module STRATEGY-UNFOLDING
4447
=> getUnfoldables(REST)
4548
rule getUnfoldables(V:Variable, REST)
4649
=> getUnfoldables(REST)
50+
rule getUnfoldables(X:SetVariable, REST)
51+
=> getUnfoldables(REST)
4752
rule getUnfoldables(\not(Ps), REST)
4853
=> getUnfoldables(Ps) ++Patterns getUnfoldables(REST)
4954
rule getUnfoldables(\and(Ps), REST)
@@ -88,7 +93,7 @@ module STRATEGY-UNFOLDING
8893
</claim>
8994
<k> left-unfold-oneBody(LRP, \exists { _ } \and(BODY)) => noop ... </k>
9095
<trace> .K => left-unfold-oneBody(LRP, \and(BODY)) ... </trace>
91-
requires #hole { getReturnSort(LRP) } in getFreeVariables(subst(LHS, LRP, #hole { getReturnSort(LRP) }))
96+
requires #hole { TopSort } in getFreeVariables(subst(LHS, LRP, #hole { TopSort }))
9297
```
9398

9499
### Left Unfold Nth

0 commit comments

Comments
 (0)