Skip to content

Commit

Permalink
Add a bigIntDiv hook
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Aug 28, 2024
1 parent 186218a commit bbf95c3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions mx-semantics/main/biguint/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module MX-BIGUINT-HOOKS
imports BOOL
imports COMMON-K-CELL
imports K-EQUAL-SYNTAX
imports MX-BIGUINT-CONFIGURATION
imports MX-COMMON-SYNTAX
Expand Down Expand Up @@ -58,6 +59,23 @@ module MX-BIGUINT-HOOKS
<bigIntHeapNextId> NextId => NextId +Int 1 </bigIntHeapNextId>
requires Id1 in_keys(Ints) andBool isInt(Ints[Id1] orDefault 0)
andBool Id2 in_keys(Ints) andBool isInt(Ints[Id2] orDefault 0)
rule
<k> MX#bigIntDiv(mxIntValue(Id1:Int) , mxIntValue(Id2:Int))
=> mxIntValue(NextId)
...
</k>
<bigIntHeap>
Ints:Map
=> Ints [ NextId
<- {Ints[Id1] orDefault 0}:>Int
/Int {Ints[Id2] orDefault 0}:>Int
]
</bigIntHeap>
<bigIntHeapNextId> NextId => NextId +Int 1 </bigIntHeapNextId>
requires Id1 in_keys(Ints) andBool isInt(Ints[Id1] orDefault 0)
andBool Id2 in_keys(Ints) andBool isInt(Ints[Id2] orDefault 0)
andBool Ints[Id2] orDefault 0 =/=K 0
endmodule
```
7 changes: 7 additions & 0 deletions tests/mx/biguint/div.mx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
push mxIntValue(40);
call 1 MX#bigIntNew;
push mxIntValue(500);
call 1 MX#bigIntNew;
call 2 MX#bigIntDiv;
get_big_int;
check_eq mxIntValue(12)

0 comments on commit bbf95c3

Please sign in to comment.