···657657 |- ?
658658659659 </hol-string-proof>
660660+ <hol-string id="index.html/string-silliness" deps="index.html/myconfig">
661661+ a.
662662+ -------------- eq-refl
663663+ (Eq a a)
664664+665665+ a. b. (Eq a b)
666666+ -------------- eq-sym
667667+ (Eq b a)
668668+669669+ a. b. c. (Eq a b) (Eq "$b" c)
670670+ -------------- eq-trans-weird
671671+ (Eq a c)
672672+673673+ -------------- eq-a-comp
674674+ (Eq "a" (Foo Bar))
675675+ </hol-string>
676676+ <hol-string-proof id="index.html/string-silliness-trip" deps="index.html/myconfig index.html/string-silliness">
677677+ ------------- eq-a-c
678678+ (Eq "a" "a")
679679+ |- ?
680680+ </hol-string-proof>
660681 <script type="module" src="./src/testcomponent.tsx"></script>
661682 </body>
662683</html>
+14-12
src/SExpFunc.res
···11+exception SubstNotCompatible(string)
22+13module type ATOM = {
24 type t
35 type subst = Map.t<int, t>
···911 // used for when trying to substitute a variable of the wrong type
1012 let lowerVar: int => option<t>
1113 let lowerSchematic: (int, array<int>) => option<t>
1212- let substDeBruijn: (t, Map.t<int, t>, ~from: int=?, ~to: int) => t
1414+ let substDeBruijn: (t, array<option<t>>, ~from: int=?) => t
1315 let concrete: t => bool
1416}
1517···142144 unifyTerm(x, y)->Seq.flatMap(s1 =>
143145 a
144146 ->Array.sliceToEnd(~start=1)
145145- ->Array.map(((t1, t2)) => (substitute(t1, s1), substitute(t2, s1)))
147147+ ->Array.filterMap(((t1, t2)) =>
148148+ try {Some((substitute(t1, s1), substitute(t2, s1)))} catch {
149149+ | SubstNotCompatible(_) => None
150150+ }
151151+ )
146152 ->unifyArray
147147- ->Seq.map(s2 => combineSubst(s1, s2))
153153+ ->Seq.filterMap(s2 =>
154154+ try {Some(combineSubst(s1, s2))} catch {
155155+ | SubstNotCompatible(_) => None
156156+ }
157157+ )
148158 )
149159 }
150160 }
···160170 }
161171 let rec substDeBruijn = (term: t, substs: array<t>, ~from: int=0) =>
162172 switch term {
163163- | Atom(s) => {
164164- let symbolSubsts =
165165- substs
166166- ->Array.mapWithIndex((t, i) => lower(t)->Option.map(a => (i, a)))
167167- ->Array.keepSome
168168- ->Map.fromArray
169169-170170- Atom(Atom.substDeBruijn(s, symbolSubsts, ~from, ~to=Array.length(substs)))
171171- }
173173+ | Atom(s) => Atom(Atom.substDeBruijn(s, Array.map(substs, lower), ~from))
172174173175 | Compound({subexps}) =>
174176 Compound({subexps: Array.map(subexps, x => substDeBruijn(x, substs, ~from))})
+9-2
src/StringA.res
···270270 }
271271272272 // law: unify(a,b) == [{}] iff equivalent(a,b)
273273- let substDeBruijn = (string: t, substs: Map.t<int, t>, ~from: int=0, ~to: int) => {
273273+ let substDeBruijn = (string: t, substs: array<option<t>>, ~from: int=0) => {
274274+ let to = Array.length(substs)
274275 Array.flatMap(string, piece =>
275276 switch piece {
276277 | String(_) => [piece]
···278279 if var < from {
279280 [piece]
280281 } else if var - from < to {
281281- Map.get(substs, var - from)->Option.getOr([piece])
282282+ switch Option.getUnsafe(substs[var - from]) {
283283+ | Some(v) => v
284284+ | None =>
285285+ throw(
286286+ SExpFunc.SubstNotCompatible(`index ${Int.toString(var - from)} not of sort string`),
287287+ )
288288+ }
282289 } else {
283290 [Var({idx: var - to})]
284291 }
···1818 let substitute = (name, _) => name
1919 let lowerVar = _ => None
2020 let lowerSchematic = (_, _) => None
2121- let substDeBruijn = (name, _, ~from as _=?, ~to as _) => name
2121+ let substDeBruijn = (name, _, ~from as _=?) => name
2222 let concrete = _ => false
2323 let upshift = (t, _, ~from as _=?) => t
2424}