amaru-uplc 0.1.0

A UPLC Evaluator as a CEK machine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
use crate::{
    builtin::DefaultFunction,
    machine::{
        cost_model::{
            builtin_costs::BuiltinCostModel,
            cost_map::CostMap,
            costing::{
                Cost, OneArgumentCosting, SixArgumentsCosting, ThreeArgumentsCosting,
                TwoArgumentsCosting,
            },
        },
        ExBudget,
    },
};

#[derive(Debug, PartialEq)]
pub struct BuiltinCostsV1 {
    add_integer: TwoArgumentsCosting,
    subtract_integer: TwoArgumentsCosting,
    multiply_integer: TwoArgumentsCosting,
    divide_integer: TwoArgumentsCosting,
    quotient_integer: TwoArgumentsCosting,
    remainder_integer: TwoArgumentsCosting,
    mod_integer: TwoArgumentsCosting,
    equals_integer: TwoArgumentsCosting,
    less_than_integer: TwoArgumentsCosting,
    less_than_equals_integer: TwoArgumentsCosting,
    // Bytestrings
    append_byte_string: TwoArgumentsCosting,
    cons_byte_string: TwoArgumentsCosting,
    slice_byte_string: ThreeArgumentsCosting,
    length_of_byte_string: OneArgumentCosting,
    index_byte_string: TwoArgumentsCosting,
    equals_byte_string: TwoArgumentsCosting,
    less_than_byte_string: TwoArgumentsCosting,
    less_than_equals_byte_string: TwoArgumentsCosting,
    // Cryptography and hashes
    sha2_256: OneArgumentCosting,
    sha3_256: OneArgumentCosting,
    blake2b_256: OneArgumentCosting,
    verify_ed25519_signature: ThreeArgumentsCosting,
    // Strings
    append_string: TwoArgumentsCosting,
    equals_string: TwoArgumentsCosting,
    encode_utf8: OneArgumentCosting,
    decode_utf8: OneArgumentCosting,
    // Bool
    if_then_else: ThreeArgumentsCosting,
    // Unit
    choose_unit: TwoArgumentsCosting,
    // Tracing
    trace: TwoArgumentsCosting,
    // Pairs
    fst_pair: OneArgumentCosting,
    snd_pair: OneArgumentCosting,
    // Lists
    choose_list: ThreeArgumentsCosting,
    mk_cons: TwoArgumentsCosting,
    head_list: OneArgumentCosting,
    tail_list: OneArgumentCosting,
    null_list: OneArgumentCosting,
    // Data
    choose_data: SixArgumentsCosting,
    constr_data: TwoArgumentsCosting,
    map_data: OneArgumentCosting,
    list_data: OneArgumentCosting,
    i_data: OneArgumentCosting,
    b_data: OneArgumentCosting,
    un_constr_data: OneArgumentCosting,
    un_map_data: OneArgumentCosting,
    un_list_data: OneArgumentCosting,
    un_i_data: OneArgumentCosting,
    un_b_data: OneArgumentCosting,
    equals_data: TwoArgumentsCosting,
    // Misc constructors
    mk_pair_data: TwoArgumentsCosting,
    mk_nil_data: OneArgumentCosting,
    mk_nil_pair_data: OneArgumentCosting,
}

impl Default for BuiltinCostsV1 {
    fn default() -> Self {
        Self {
            add_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::max_size(1, 1),
                TwoArgumentsCosting::max_size(100788, 420),
            ),
            subtract_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::max_size(1, 1),
                TwoArgumentsCosting::max_size(100788, 420),
            ),
            multiply_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::added_sizes(0, 1),
                TwoArgumentsCosting::multiplied_sizes(90434, 519),
            ),
            divide_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::subtracted_sizes(0, 1, 1),
                TwoArgumentsCosting::const_above_diagonal_into_multiplied_sizes(85848, 228465, 122),
            ),
            quotient_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::subtracted_sizes(0, 1, 1),
                TwoArgumentsCosting::const_above_diagonal_into_multiplied_sizes(85848, 228465, 122),
            ),
            remainder_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::subtracted_sizes(0, 1, 1),
                TwoArgumentsCosting::const_above_diagonal_into_multiplied_sizes(85848, 228465, 122),
            ),
            mod_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::subtracted_sizes(0, 1, 1),
                TwoArgumentsCosting::const_above_diagonal_into_multiplied_sizes(85848, 228465, 122),
            ),
            equals_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(1),
                TwoArgumentsCosting::min_size(51775, 558),
            ),
            less_than_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(1),
                TwoArgumentsCosting::min_size(44749, 541),
            ),
            less_than_equals_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(1),
                TwoArgumentsCosting::min_size(43285, 552),
            ),
            append_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::added_sizes(0, 1),
                TwoArgumentsCosting::added_sizes(1000, 173),
            ),
            cons_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::added_sizes(0, 1),
                TwoArgumentsCosting::linear_in_y(72010, 178),
            ),
            slice_byte_string: ThreeArgumentsCosting::new(
                ThreeArgumentsCosting::linear_in_z(4, 0),
                ThreeArgumentsCosting::linear_in_z(20467, 1),
            ),
            length_of_byte_string: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(10),
                OneArgumentCosting::constant_cost(22100),
            ),
            index_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(4),
                TwoArgumentsCosting::constant_cost(13169),
            ),
            equals_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(1),
                TwoArgumentsCosting::linear_on_diagonal(24548, 29498, 38),
            ),
            less_than_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(1),
                TwoArgumentsCosting::min_size(28999, 74),
            ),
            less_than_equals_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(1),
                TwoArgumentsCosting::min_size(28999, 74),
            ),
            sha2_256: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(4),
                OneArgumentCosting::linear_cost(270652, 22588),
            ),
            sha3_256: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(4),
                OneArgumentCosting::linear_cost(1457325, 64566),
            ),
            blake2b_256: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(4),
                OneArgumentCosting::linear_cost(201305, 8356),
            ),
            verify_ed25519_signature: ThreeArgumentsCosting::new(
                ThreeArgumentsCosting::constant_cost(10),
                ThreeArgumentsCosting::linear_in_y(53384111, 14333),
            ),
            append_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::added_sizes(4, 1),
                TwoArgumentsCosting::added_sizes(1000, 59957),
            ),
            equals_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(1),
                TwoArgumentsCosting::linear_on_diagonal(39184, 1000, 60594),
            ),
            encode_utf8: OneArgumentCosting::new(
                OneArgumentCosting::linear_cost(4, 2),
                OneArgumentCosting::linear_cost(1000, 42921),
            ),
            decode_utf8: OneArgumentCosting::new(
                OneArgumentCosting::linear_cost(4, 2),
                OneArgumentCosting::linear_cost(91189, 769),
            ),
            if_then_else: ThreeArgumentsCosting::new(
                ThreeArgumentsCosting::constant_cost(1),
                ThreeArgumentsCosting::constant_cost(76049),
            ),
            choose_unit: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(4),
                TwoArgumentsCosting::constant_cost(61462),
            ),
            trace: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(32),
                TwoArgumentsCosting::constant_cost(59498),
            ),
            fst_pair: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(141895),
            ),
            snd_pair: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(141992),
            ),
            choose_list: ThreeArgumentsCosting::new(
                ThreeArgumentsCosting::constant_cost(32),
                ThreeArgumentsCosting::constant_cost(132994),
            ),
            mk_cons: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(32),
                TwoArgumentsCosting::constant_cost(72362),
            ),
            head_list: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(83150),
            ),
            tail_list: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(81663),
            ),
            null_list: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(74433),
            ),
            choose_data: SixArgumentsCosting::new(
                SixArgumentsCosting::constant_cost(32),
                SixArgumentsCosting::constant_cost(94375),
            ),
            constr_data: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(32),
                TwoArgumentsCosting::constant_cost(22151),
            ),
            map_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(68246),
            ),
            list_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(33852),
            ),
            i_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(15299),
            ),
            b_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(11183),
            ),
            un_constr_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(24588),
            ),
            un_map_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(24623),
            ),
            un_list_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(25933),
            ),
            un_i_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(20744),
            ),
            un_b_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(20142),
            ),
            equals_data: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(1),
                TwoArgumentsCosting::min_size(898148, 27279),
            ),
            mk_pair_data: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(32),
                TwoArgumentsCosting::constant_cost(11546),
            ),
            mk_nil_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(7243),
            ),
            mk_nil_pair_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(32),
                OneArgumentCosting::constant_cost(7391),
            ),
        }
    }
}

impl BuiltinCostModel for BuiltinCostsV1 {
    fn initialize(cost_map: &CostMap) -> Self {
        Self {
            add_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::max_size(
                    cost_map["add_integer-mem-arguments-intercept"],
                    cost_map["add_integer-mem-arguments-slope"],
                ),
                TwoArgumentsCosting::max_size(
                    cost_map["add_integer-cpu-arguments-intercept"],
                    cost_map["add_integer-cpu-arguments-slope"],
                ),
            ),

            append_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::added_sizes(
                    cost_map["append_byte_string-mem-arguments-intercept"],
                    cost_map["append_byte_string-mem-arguments-slope"],
                ),
                TwoArgumentsCosting::added_sizes(
                    cost_map["append_byte_string-cpu-arguments-intercept"],
                    cost_map["append_byte_string-cpu-arguments-slope"],
                ),
            ),

            append_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::added_sizes(
                    cost_map["append_string-mem-arguments-intercept"],
                    cost_map["append_string-mem-arguments-slope"],
                ),
                TwoArgumentsCosting::added_sizes(
                    cost_map["append_string-cpu-arguments-intercept"],
                    cost_map["append_string-cpu-arguments-slope"],
                ),
            ),

            b_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["b_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["b_data-cpu-arguments"]),
            ),

            blake2b_256: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["blake2b_256-mem-arguments"]),
                OneArgumentCosting::linear_cost(
                    cost_map["blake2b_256-cpu-arguments-intercept"],
                    cost_map["blake2b_256-cpu-arguments-slope"],
                ),
            ),
            choose_data: SixArgumentsCosting::new(
                SixArgumentsCosting::constant_cost(cost_map["choose_data-mem-arguments"]),
                SixArgumentsCosting::constant_cost(cost_map["choose_data-cpu-arguments"]),
            ),
            choose_list: ThreeArgumentsCosting::new(
                ThreeArgumentsCosting::constant_cost(cost_map["choose_list-mem-arguments"]),
                ThreeArgumentsCosting::constant_cost(cost_map["choose_list-cpu-arguments"]),
            ),
            choose_unit: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["choose_unit-mem-arguments"]),
                TwoArgumentsCosting::constant_cost(cost_map["choose_unit-cpu-arguments"]),
            ),
            cons_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::added_sizes(
                    cost_map["cons_byte_string-mem-arguments-intercept"],
                    cost_map["cons_byte_string-mem-arguments-slope"],
                ),
                TwoArgumentsCosting::linear_in_y(
                    cost_map["cons_byte_string-cpu-arguments-intercept"],
                    cost_map["cons_byte_string-cpu-arguments-slope"],
                ),
            ),
            constr_data: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["constr_data-mem-arguments"]),
                TwoArgumentsCosting::constant_cost(cost_map["constr_data-cpu-arguments"]),
            ),
            decode_utf8: OneArgumentCosting::new(
                OneArgumentCosting::linear_cost(
                    cost_map["decode_utf8-mem-arguments-intercept"],
                    cost_map["decode_utf8-mem-arguments-slope"],
                ),
                OneArgumentCosting::linear_cost(
                    cost_map["decode_utf8-cpu-arguments-intercept"],
                    cost_map["decode_utf8-cpu-arguments-slope"],
                ),
            ),
            divide_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::subtracted_sizes(
                    cost_map["divide_integer-mem-arguments-intercept"],
                    cost_map["divide_integer-mem-arguments-minimum"],
                    cost_map["divide_integer-mem-arguments-slope"],
                ),
                TwoArgumentsCosting::const_above_diagonal_into_multiplied_sizes(
                    cost_map["divide_integer-cpu-arguments-constant"],
                    cost_map["divide_integer-cpu-arguments-model-arguments-intercept"],
                    cost_map["divide_integer-cpu-arguments-model-arguments-slope"],
                ),
            ),
            encode_utf8: OneArgumentCosting::new(
                OneArgumentCosting::linear_cost(
                    cost_map["encode_utf8-mem-arguments-intercept"],
                    cost_map["encode_utf8-mem-arguments-slope"],
                ),
                OneArgumentCosting::linear_cost(
                    cost_map["encode_utf8-cpu-arguments-intercept"],
                    cost_map["encode_utf8-cpu-arguments-slope"],
                ),
            ),
            equals_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["equals_byte_string-mem-arguments"]),
                TwoArgumentsCosting::linear_on_diagonal(
                    cost_map["equals_byte_string-cpu-arguments-constant"],
                    cost_map["equals_byte_string-cpu-arguments-intercept"],
                    cost_map["equals_byte_string-cpu-arguments-slope"],
                ),
            ),
            equals_data: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["equals_data-mem-arguments"]),
                TwoArgumentsCosting::min_size(
                    cost_map["equals_data-cpu-arguments-intercept"],
                    cost_map["equals_data-cpu-arguments-slope"],
                ),
            ),
            equals_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["equals_integer-mem-arguments"]),
                TwoArgumentsCosting::min_size(
                    cost_map["equals_integer-cpu-arguments-intercept"],
                    cost_map["equals_integer-cpu-arguments-slope"],
                ),
            ),
            equals_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["equals_string-mem-arguments"]),
                TwoArgumentsCosting::linear_on_diagonal(
                    cost_map["equals_string-cpu-arguments-constant"],
                    cost_map["equals_string-cpu-arguments-intercept"],
                    cost_map["equals_string-cpu-arguments-slope"],
                ),
            ),
            fst_pair: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["fst_pair-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["fst_pair-cpu-arguments"]),
            ),
            head_list: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["head_list-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["head_list-cpu-arguments"]),
            ),
            i_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["i_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["i_data-cpu-arguments"]),
            ),
            if_then_else: ThreeArgumentsCosting::new(
                ThreeArgumentsCosting::constant_cost(cost_map["if_then_else-mem-arguments"]),
                ThreeArgumentsCosting::constant_cost(cost_map["if_then_else-cpu-arguments"]),
            ),
            index_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["index_byte_string-mem-arguments"]),
                TwoArgumentsCosting::constant_cost(cost_map["index_byte_string-cpu-arguments"]),
            ),
            length_of_byte_string: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["length_of_byte_string-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["length_of_byte_string-cpu-arguments"]),
            ),
            less_than_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["less_than_byte_string-mem-arguments"]),
                TwoArgumentsCosting::min_size(
                    cost_map["less_than_byte_string-cpu-arguments-intercept"],
                    cost_map["less_than_byte_string-cpu-arguments-slope"],
                ),
            ),
            less_than_equals_byte_string: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(
                    cost_map["less_than_equals_byte_string-mem-arguments"],
                ),
                TwoArgumentsCosting::min_size(
                    cost_map["less_than_equals_byte_string-cpu-arguments-intercept"],
                    cost_map["less_than_equals_byte_string-cpu-arguments-slope"],
                ),
            ),
            less_than_equals_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(
                    cost_map["less_than_equals_integer-mem-arguments"],
                ),
                TwoArgumentsCosting::min_size(
                    cost_map["less_than_equals_integer-cpu-arguments-intercept"],
                    cost_map["less_than_equals_integer-cpu-arguments-slope"],
                ),
            ),
            less_than_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["less_than_integer-mem-arguments"]),
                TwoArgumentsCosting::min_size(
                    cost_map["less_than_integer-cpu-arguments-intercept"],
                    cost_map["less_than_integer-cpu-arguments-slope"],
                ),
            ),
            list_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["list_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["list_data-cpu-arguments"]),
            ),
            map_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["map_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["map_data-cpu-arguments"]),
            ),
            mk_cons: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["mk_cons-mem-arguments"]),
                TwoArgumentsCosting::constant_cost(cost_map["mk_cons-cpu-arguments"]),
            ),
            mk_nil_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["mk_nil_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["mk_nil_data-cpu-arguments"]),
            ),
            mk_nil_pair_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["mk_nil_pair_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["mk_nil_pair_data-cpu-arguments"]),
            ),
            mk_pair_data: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["mk_pair_data-mem-arguments"]),
                TwoArgumentsCosting::constant_cost(cost_map["mk_pair_data-cpu-arguments"]),
            ),
            mod_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::subtracted_sizes(
                    cost_map["mod_integer-mem-arguments-intercept"],
                    cost_map["mod_integer-mem-arguments-slope"],
                    cost_map["mod_integer-mem-arguments-minimum"],
                ),
                TwoArgumentsCosting::const_above_diagonal_into_multiplied_sizes(
                    cost_map["mod_integer-cpu-arguments-constant"],
                    cost_map["mod_integer-cpu-arguments-model-arguments-intercept"],
                    cost_map["mod_integer-cpu-arguments-model-arguments-slope"],
                ),
            ),
            multiply_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::added_sizes(
                    cost_map["multiply_integer-mem-arguments-intercept"],
                    cost_map["multiply_integer-mem-arguments-slope"],
                ),
                TwoArgumentsCosting::multiplied_sizes(
                    cost_map["multiply_integer-cpu-arguments-intercept"],
                    cost_map["multiply_integer-cpu-arguments-slope"],
                ),
            ),
            null_list: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["null_list-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["null_list-cpu-arguments"]),
            ),
            quotient_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::subtracted_sizes(
                    cost_map["quotient_integer-mem-arguments-intercept"],
                    cost_map["quotient_integer-mem-arguments-slope"],
                    cost_map["quotient_integer-mem-arguments-minimum"],
                ),
                TwoArgumentsCosting::const_above_diagonal_into_multiplied_sizes(
                    cost_map["quotient_integer-cpu-arguments-constant"],
                    cost_map["quotient_integer-cpu-arguments-model-arguments-intercept"],
                    cost_map["quotient_integer-cpu-arguments-model-arguments-slope"],
                ),
            ),
            remainder_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::subtracted_sizes(
                    cost_map["remainder_integer-mem-arguments-intercept"],
                    cost_map["remainder_integer-mem-arguments-slope"],
                    cost_map["remainder_integer-mem-arguments-minimum"],
                ),
                TwoArgumentsCosting::const_above_diagonal_into_multiplied_sizes(
                    cost_map["remainder_integer-cpu-arguments-constant"],
                    cost_map["remainder_integer-cpu-arguments-model-arguments-intercept"],
                    cost_map["remainder_integer-cpu-arguments-model-arguments-slope"],
                ),
            ),
            sha2_256: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["sha2_256-mem-arguments"]),
                OneArgumentCosting::linear_cost(
                    cost_map["sha2_256-cpu-arguments-intercept"],
                    cost_map["sha2_256-cpu-arguments-slope"],
                ),
            ),
            sha3_256: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["sha3_256-mem-arguments"]),
                OneArgumentCosting::linear_cost(
                    cost_map["sha3_256-cpu-arguments-intercept"],
                    cost_map["sha3_256-cpu-arguments-slope"],
                ),
            ),
            slice_byte_string: ThreeArgumentsCosting::new(
                ThreeArgumentsCosting::linear_in_z(
                    cost_map["slice_byte_string-mem-arguments-intercept"],
                    cost_map["slice_byte_string-mem-arguments-slope"],
                ),
                ThreeArgumentsCosting::linear_in_z(
                    cost_map["slice_byte_string-cpu-arguments-intercept"],
                    cost_map["slice_byte_string-cpu-arguments-slope"],
                ),
            ),
            snd_pair: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["snd_pair-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["snd_pair-cpu-arguments"]),
            ),
            subtract_integer: TwoArgumentsCosting::new(
                TwoArgumentsCosting::max_size(
                    cost_map["subtract_integer-mem-arguments-intercept"],
                    cost_map["subtract_integer-mem-arguments-slope"],
                ),
                TwoArgumentsCosting::max_size(
                    cost_map["subtract_integer-cpu-arguments-intercept"],
                    cost_map["subtract_integer-cpu-arguments-slope"],
                ),
            ),
            tail_list: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["tail_list-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["tail_list-cpu-arguments"]),
            ),
            trace: TwoArgumentsCosting::new(
                TwoArgumentsCosting::constant_cost(cost_map["trace-mem-arguments"]),
                TwoArgumentsCosting::constant_cost(cost_map["trace-cpu-arguments"]),
            ),
            un_b_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["un_b_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["un_b_data-cpu-arguments"]),
            ),
            un_constr_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["un_constr_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["un_constr_data-cpu-arguments"]),
            ),
            un_i_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["un_i_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["un_i_data-cpu-arguments"]),
            ),
            un_list_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["un_list_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["un_list_data-cpu-arguments"]),
            ),
            un_map_data: OneArgumentCosting::new(
                OneArgumentCosting::constant_cost(cost_map["un_map_data-mem-arguments"]),
                OneArgumentCosting::constant_cost(cost_map["un_map_data-cpu-arguments"]),
            ),
            verify_ed25519_signature: ThreeArgumentsCosting::new(
                ThreeArgumentsCosting::constant_cost(
                    cost_map["verify_ed25519_signature-mem-arguments"],
                ),
                ThreeArgumentsCosting::linear_in_y(
                    cost_map["verify_ed25519_signature-cpu-arguments-intercept"],
                    cost_map["verify_ed25519_signature-cpu-arguments-slope"],
                ),
            ),
        }
    }

    fn get_cost(&self, builtin: DefaultFunction, args: &[i64]) -> Option<ExBudget> {
        match builtin {
            DefaultFunction::AddInteger => Some(ExBudget::new(
                self.add_integer.mem.cost([args[0], args[1]]),
                self.add_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::SubtractInteger => Some(ExBudget::new(
                self.subtract_integer.mem.cost([args[0], args[1]]),
                self.subtract_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::MultiplyInteger => Some(ExBudget::new(
                self.multiply_integer.mem.cost([args[0], args[1]]),
                self.multiply_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::DivideInteger => Some(ExBudget::new(
                self.divide_integer.mem.cost([args[0], args[1]]),
                self.divide_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::QuotientInteger => Some(ExBudget::new(
                self.quotient_integer.mem.cost([args[0], args[1]]),
                self.quotient_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::RemainderInteger => Some(ExBudget::new(
                self.remainder_integer.mem.cost([args[0], args[1]]),
                self.remainder_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::ModInteger => Some(ExBudget::new(
                self.mod_integer.mem.cost([args[0], args[1]]),
                self.mod_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::EqualsInteger => Some(ExBudget::new(
                self.equals_integer.mem.cost([args[0], args[1]]),
                self.equals_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::LessThanInteger => Some(ExBudget::new(
                self.less_than_integer.mem.cost([args[0], args[1]]),
                self.less_than_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::LessThanEqualsInteger => Some(ExBudget::new(
                self.less_than_equals_integer.mem.cost([args[0], args[1]]),
                self.less_than_equals_integer.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::AppendByteString => Some(ExBudget::new(
                self.append_byte_string.mem.cost([args[0], args[1]]),
                self.append_byte_string.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::ConsByteString => Some(ExBudget::new(
                self.cons_byte_string.mem.cost([args[0], args[1]]),
                self.cons_byte_string.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::SliceByteString => Some(ExBudget::new(
                self.slice_byte_string.mem.cost([args[0], args[1], args[2]]),
                self.slice_byte_string.cpu.cost([args[0], args[1], args[2]]),
            )),
            DefaultFunction::LengthOfByteString => Some(ExBudget::new(
                self.length_of_byte_string.mem.cost([args[0]]),
                self.length_of_byte_string.cpu.cost([args[0]]),
            )),
            DefaultFunction::IndexByteString => Some(ExBudget::new(
                self.index_byte_string.mem.cost([args[0], args[1]]),
                self.index_byte_string.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::EqualsByteString => Some(ExBudget::new(
                self.equals_byte_string.mem.cost([args[0], args[1]]),
                self.equals_byte_string.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::LessThanByteString => Some(ExBudget::new(
                self.less_than_byte_string.mem.cost([args[0], args[1]]),
                self.less_than_byte_string.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::LessThanEqualsByteString => Some(ExBudget::new(
                self.less_than_equals_byte_string
                    .mem
                    .cost([args[0], args[1]]),
                self.less_than_equals_byte_string
                    .cpu
                    .cost([args[0], args[1]]),
            )),
            DefaultFunction::Sha2_256 => Some(ExBudget::new(
                self.sha2_256.mem.cost([args[0]]),
                self.sha2_256.cpu.cost([args[0]]),
            )),
            DefaultFunction::Sha3_256 => Some(ExBudget::new(
                self.sha3_256.mem.cost([args[0]]),
                self.sha3_256.cpu.cost([args[0]]),
            )),
            DefaultFunction::Blake2b_256 => Some(ExBudget::new(
                self.blake2b_256.mem.cost([args[0]]),
                self.blake2b_256.cpu.cost([args[0]]),
            )),
            DefaultFunction::VerifyEd25519Signature => Some(ExBudget::new(
                self.verify_ed25519_signature
                    .mem
                    .cost([args[0], args[1], args[2]]),
                self.verify_ed25519_signature
                    .cpu
                    .cost([args[0], args[1], args[2]]),
            )),
            DefaultFunction::AppendString => Some(ExBudget::new(
                self.append_string.mem.cost([args[0], args[1]]),
                self.append_string.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::EqualsString => Some(ExBudget::new(
                self.equals_string.mem.cost([args[0], args[1]]),
                self.equals_string.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::EncodeUtf8 => Some(ExBudget::new(
                self.encode_utf8.mem.cost([args[0]]),
                self.encode_utf8.cpu.cost([args[0]]),
            )),
            DefaultFunction::DecodeUtf8 => Some(ExBudget::new(
                self.decode_utf8.mem.cost([args[0]]),
                self.decode_utf8.cpu.cost([args[0]]),
            )),
            DefaultFunction::IfThenElse => Some(ExBudget::new(
                self.if_then_else.mem.cost([args[0], args[1], args[2]]),
                self.if_then_else.cpu.cost([args[0], args[1], args[2]]),
            )),
            DefaultFunction::ChooseUnit => Some(ExBudget::new(
                self.choose_unit.mem.cost([args[0], args[1]]),
                self.choose_unit.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::Trace => Some(ExBudget::new(
                self.trace.mem.cost([args[0], args[1]]),
                self.trace.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::FstPair => Some(ExBudget::new(
                self.fst_pair.mem.cost([args[0]]),
                self.fst_pair.cpu.cost([args[0]]),
            )),
            DefaultFunction::SndPair => Some(ExBudget::new(
                self.snd_pair.mem.cost([args[0]]),
                self.snd_pair.cpu.cost([args[0]]),
            )),
            DefaultFunction::ChooseList => Some(ExBudget::new(
                self.choose_list.mem.cost([args[0], args[1], args[2]]),
                self.choose_list.cpu.cost([args[0], args[1], args[2]]),
            )),
            DefaultFunction::MkCons => Some(ExBudget::new(
                self.mk_cons.mem.cost([args[0], args[1]]),
                self.mk_cons.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::HeadList => Some(ExBudget::new(
                self.head_list.mem.cost([args[0]]),
                self.head_list.cpu.cost([args[0]]),
            )),
            DefaultFunction::TailList => Some(ExBudget::new(
                self.tail_list.mem.cost([args[0]]),
                self.tail_list.cpu.cost([args[0]]),
            )),
            DefaultFunction::NullList => Some(ExBudget::new(
                self.null_list.mem.cost([args[0]]),
                self.null_list.cpu.cost([args[0]]),
            )),
            DefaultFunction::ChooseData => Some(ExBudget::new(
                self.choose_data
                    .mem
                    .cost([args[0], args[1], args[2], args[3], args[4], args[5]]),
                self.choose_data
                    .cpu
                    .cost([args[0], args[1], args[2], args[3], args[4], args[5]]),
            )),
            DefaultFunction::ConstrData => Some(ExBudget::new(
                self.constr_data.mem.cost([args[0], args[1]]),
                self.constr_data.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::MapData => Some(ExBudget::new(
                self.map_data.mem.cost([args[0]]),
                self.map_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::ListData => Some(ExBudget::new(
                self.list_data.mem.cost([args[0]]),
                self.list_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::IData => Some(ExBudget::new(
                self.i_data.mem.cost([args[0]]),
                self.i_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::BData => Some(ExBudget::new(
                self.b_data.mem.cost([args[0]]),
                self.b_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::UnConstrData => Some(ExBudget::new(
                self.un_constr_data.mem.cost([args[0]]),
                self.un_constr_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::UnMapData => Some(ExBudget::new(
                self.un_map_data.mem.cost([args[0]]),
                self.un_map_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::UnListData => Some(ExBudget::new(
                self.un_list_data.mem.cost([args[0]]),
                self.un_list_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::UnIData => Some(ExBudget::new(
                self.un_i_data.mem.cost([args[0]]),
                self.un_i_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::UnBData => Some(ExBudget::new(
                self.un_b_data.mem.cost([args[0]]),
                self.un_b_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::EqualsData => Some(ExBudget::new(
                self.equals_data.mem.cost([args[0], args[1]]),
                self.equals_data.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::MkPairData => Some(ExBudget::new(
                self.mk_pair_data.mem.cost([args[0], args[1]]),
                self.mk_pair_data.cpu.cost([args[0], args[1]]),
            )),
            DefaultFunction::MkNilData => Some(ExBudget::new(
                self.mk_nil_data.mem.cost([args[0]]),
                self.mk_nil_data.cpu.cost([args[0]]),
            )),
            DefaultFunction::MkNilPairData => Some(ExBudget::new(
                self.mk_nil_pair_data.mem.cost([args[0]]),
                self.mk_nil_pair_data.cpu.cost([args[0]]),
            )),
            _ => None,
        }
    }
}