From b539ee5bf314bb4ed5df92ada1e0319fefc647ec Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Thu, 25 Dec 2025 22:00:14 +1300 Subject: Reorganisation and additional numeric comparison subprograms --- src/kompsos-math.adb | 511 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 298 insertions(+), 213 deletions(-) (limited to 'src/kompsos-math.adb') diff --git a/src/kompsos-math.adb b/src/kompsos-math.adb index b64d393..7ea6310 100644 --- a/src/kompsos-math.adb +++ b/src/kompsos-math.adb @@ -18,6 +18,16 @@ package body Kompsos.Math is -- Can't apply 'Unchecked_Access to a subprogram either, so we're doing this. + LT_Length_Access : constant access function + (This : in Goal; + Inputs : in Term_Array) + return Goal := LT_Length'Access; + + EQ_Length_Access : constant access function + (This : in Goal; + Inputs : in Term_Array) + return Goal := EQ_Length'Access; + Adder_Access : constant access function (This : in Goal; Inputs : in Term_Array) @@ -43,16 +53,6 @@ package body Kompsos.Math is Inputs : in Term_Array) return Goal := Bounded_Multiply'Access; - EQ_Length_Access : constant access function - (This : in Goal; - Inputs : in Term_Array) - return Goal := EQ_Length'Access; - - LT_Length_Access : constant access function - (This : in Goal; - Inputs : in Term_Array) - return Goal := LT_Length'Access; - @@ -110,7 +110,294 @@ package body Kompsos.Math is ------------------ - -- Operations -- + -- Comparison -- + ------------------ + + -- poso -- + + function GT_Zero + (This : in Goal; + Num_Term : in Term'Class) + return Goal is + begin + return This.Pair (Num_Term); + end GT_Zero; + + + procedure GT_Zero + (This : in out Goal; + Num_Term : in Term'Class) is + begin + This := GT_Zero (This, Num_Term); + end GT_Zero; + + + + -- >1o -- + + function GT_One + (This : in Goal; + Num_Term : in Term'Class) + return Goal + is + Result : Goal := This; + Ref_Term : constant Term := Result.Fresh; + begin + Result.Tail (Num_Term & Ref_Term); + Result.Pair (Ref_Term); + return Result; + end GT_One; + + + procedure GT_One + (This : in out Goal; + Num_Term : in Term'Class) is + begin + This := GT_One (This, Num_Term); + end GT_One; + + + + -- 1o -- - - function GT_One - (This : in Goal; - Num_Term : in Term'Class) - return Goal - is - Result : Goal := This; - Ref_Term : constant Term := Result.Fresh; - begin - Result.Tail (Num_Term & Ref_Term); - Result.Pair (Ref_Term); - return Result; - end GT_One; - - - procedure GT_One - (This : in out Goal; - Num_Term : in Term'Class) is - begin - This := GT_One (This, Num_Term); - end GT_One; - - - -- addero -- function Adder @@ -517,163 +759,6 @@ package body Kompsos.Math is end Bounded_Multiply; - - -- =lo -- - - function EQ_Length - (This : in Goal; - Inputs : in Term_Array) - return Goal - is - N_Term : Term renames Inputs (1); - M_Term : Term renames Inputs (2); - - One, Two, Three : Goal := This; - - X_Var : constant Term := Three.Fresh; - Y_Var : constant Term := Three.Fresh; - begin - One.Unify (N_Term, Zero_Term); - One.Unify (M_Term, Zero_Term); - - Two.Unify (N_Term, One_Term); - Two.Unify (M_Term, One_Term); - - Three.Unify (N_Term, T (Three.Fresh, X_Var)); - GT_Zero (Three, X_Var); - Three.Unify (M_Term, T (Three.Fresh, Y_Var)); - GT_Zero (Three, Y_Var); - Three.Conjunct (EQ_Length_Access, X_Var & Y_Var); - - return Disjunct (One & Two & Three); - end EQ_Length; - - - procedure EQ_Length - (This : in out Goal; - Inputs : in Term_Array) is - begin - This := EQ_Length (This, Inputs); - end EQ_Length; - - - - --