Major overhaul of the type system to manage typed proof search with an easier-to-maintain and less invasive API#53
Conversation
2780a16 to
cc89202
Compare
cc89202 to
f0c5429
Compare
f0c5429 to
c064455
Compare
ab5b778 to
917dfa1
Compare
6524fb1 to
ab51ebc
Compare
| func (a All) Equals(other any) bool { | ||
| if typed, ok := other.(All); ok { | ||
| return AreEqualsVarList(a.GetVarList(), typed.GetVarList()) && a.GetForm().Equals(typed.GetForm()) | ||
| return a.quantifier.Equals(typed.quantifier) |
There was a problem hiding this comment.
We don't have to check the variable list anymore?
There was a problem hiding this comment.
It is checked but inside the quantifier interface instead.
| if !replaced { | ||
| newBv := MkTyBV(newVar.name, newVar.index) | ||
| f = f.SubstTy(v.ToTyBoundVar(), newBv) | ||
| newTyBv.Append(Lib.MkPair(v.ToTyBoundVar(), newBv)) | ||
| } |
There was a problem hiding this comment.
It wasn't there before, why do we need that now?
There was a problem hiding this comment.
This is because previously quantifiers over terms and types were heterogeneous: there was an All formula and an AllType formula. Now we have unified these two to simplify the interface and so we have to substitute either in the term or in the type. If we cannot substitute in the term, then the variable either does not appear in the formula or it appears in the types, so we try to substitute it inside the type.
Anyway the function renaming bound variables is bound to disappear (no pun intended) once bound variables are transformed into de bruijn indices.
| // context := AST.GetGlobalContext() | ||
| // for k, v := range context { | ||
| // if k != "=" && k[0] != '$' { | ||
| // switch typed := v[0].App.(type) { | ||
| // case AST.TypeArrow: | ||
| // primitives := typed.GetPrimitives() | ||
| // typesStr := "" | ||
|
|
||
| // for i, prim := range primitives { | ||
| // if i != len(primitives)-1 { | ||
| // typesStr += "τ (" + prim.ToString() + ") → " | ||
| // } else { | ||
| // typesStr += prim.ToString() | ||
| // } | ||
| // } | ||
| // arrows = append(arrows, Glob.MakePair(k, typesStr)) | ||
| // case AST.QuantifiedType: | ||
| // primitives := typed.GetPrimitives() | ||
| // typesStr := "" | ||
| // contextualized := []string{} | ||
|
|
||
| // for i, prim := range primitives { | ||
| // if i != len(primitives)-1 { | ||
| // switch typedPrim := prim.(type) { | ||
| // case AST.TypeVar: | ||
| // str := AST.SimpleStringMappable(typedPrim.ToString()) | ||
| // symbol := addToContext(&str) | ||
| // typesStr += "τ (" + symbol + ") → " | ||
| // contextualized = append(contextualized, symbol) | ||
| // case AST.TypeHint: | ||
| // typesStr += "τ (" + prim.ToString() + ") → " | ||
| // } | ||
| // } else { | ||
| // typesStr += prim.ToString() | ||
| // } | ||
| // } | ||
| // arrows = append(arrows, Glob.MakePair(k, fmt.Sprintf("Π (%s : Type), %s", strings.Join(contextualized, " : Type), ("), typesStr))) | ||
| // case AST.TypeHint: | ||
| // if k == typed.ToString() { | ||
| // types = append(types, Glob.MakePair(k, "Type")) | ||
| // } else { | ||
| // others = append(others, Glob.MakePair(k, fmt.Sprintf("τ (%s)", typed.ToString()))) | ||
| // } | ||
| // } | ||
| // } | ||
| // } | ||
|
|
||
| // return types, arrows, others |
There was a problem hiding this comment.
Yes we actually want to do something alike when fixing the LP output (#67)
| // } else { | ||
| // context := AST.GetGlobalContext() | ||
| // for k, v := range context { | ||
| // if typed, ok := v[0].App.(AST.TypeHint); ok { | ||
| // if k[0] != '$' && k == typed.ToString() { | ||
| // resultingString += "Parameter " + k + ": Type.\n" | ||
|
|
||
| // } | ||
| // } | ||
| // } | ||
|
|
||
| // resultingString += strings.Join(getContextFromFormula(root), "\n") + "\n" | ||
|
|
||
| // if metaList.Len() > 0 { | ||
| // resultingString += contextualizeMetas(metaList) | ||
| // } | ||
| // } |
There was a problem hiding this comment.
Yes we actually want to keep it to do the same thing when fixing the rocq output (#59)
ab51ebc to
54a1cd4
Compare
* non destructive search **does not** manage typed search, only destructive search does * dmt might be incompatible with typed search
54a1cd4 to
7695826
Compare
Bug fix
Closes: #38
Description
I've totally removed the old typing system and reworked it in something new:
MixedSubstitution, which stores both term and type substitutions. Adapted the destructive proof search to make use of it. DMT is not fully supported yet, but I think the update is straightforward. Non-destructive search does not support mixed substitutions (as an aside, maybe we should cleanup the non destructive version, it doesn't work anyway so we could simply return errors saying this isn't implemented yet or simply remove the option to do non-destructive search).PR dependencies
*FormListbyLib.List[Form]#46Test-suite update
test-suite/proofs/tf1_basic_thm.ptest-suite/proofs/tf1_basic_thm-2.ptest-suite/bugs/bug_53-1.ptest-suite/basic/test-typing-elab-n.pto check the ad-hoc polymorphism of defined arithmetic functions and the edge case of quotients