mirror of
https://github.com/CatalaLang/catala.git
synced 2024-09-19 16:28:12 +03:00
Added assertions, starting to execute section132
This commit is contained in:
parent
26eff2a49f
commit
ebf14f6121
26
Makefile
26
Makefile
@ -109,23 +109,24 @@ CODE_GENERAL_IMPOTS_DIR=$(EXAMPLES_DIR)/code_general_impots
|
||||
US_TAX_CODE_DIR=$(EXAMPLES_DIR)/us_tax_code
|
||||
TUTORIAL_DIR=$(EXAMPLES_DIR)/tutorial
|
||||
|
||||
allocations_familiales: pygments build
|
||||
literate_allocations_familiales: pygments build
|
||||
$(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) $@.tex
|
||||
$(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) $@.html
|
||||
|
||||
code_general_impots: pygments build
|
||||
literate_code_general_impots: pygments build
|
||||
$(MAKE) -C $(CODE_GENERAL_IMPOTS_DIR) $@.tex
|
||||
$(MAKE) -C $(CODE_GENERAL_IMPOTS_DIR) $@.html
|
||||
|
||||
us_tax_code: pygments build
|
||||
literate_us_tax_code: pygments build
|
||||
$(MAKE) -C $(US_TAX_CODE_DIR) $@.tex
|
||||
$(MAKE) -C $(US_TAX_CODE_DIR) $@.html
|
||||
|
||||
tutorial_en: pygments build
|
||||
literate_tutorial_en: pygments build
|
||||
$(MAKE) -C $(TUTORIAL_DIR) $@.tex
|
||||
$(MAKE) -C $(TUTORIAL_DIR) $@.html
|
||||
|
||||
all_examples: allocations_familiales code_general_impots us_tax_code tutorial_en
|
||||
literate_examples: literate_allocations_familiales literate_code_general_impots \
|
||||
literate_us_tax_code literate_tutorial_en
|
||||
|
||||
##########################################
|
||||
# Execute test suite
|
||||
@ -133,8 +134,13 @@ all_examples: allocations_familiales code_general_impots us_tax_code tutorial_en
|
||||
|
||||
.FORCE:
|
||||
|
||||
tests: build .FORCE
|
||||
$(MAKE) -C tests
|
||||
test_suite: .FORCE
|
||||
@$(MAKE) --no-print-directory -C tests
|
||||
|
||||
test_examples: .FORCE
|
||||
@$(MAKE) --no-print-directory -C examples test_examples
|
||||
|
||||
tests: test_suite test_examples
|
||||
|
||||
##########################################
|
||||
# Website assets
|
||||
@ -147,13 +153,13 @@ catala.html: src/catala/utils/cli.ml
|
||||
dune exec src/catala.exe -- --help=groff | man2html | sed -e '1,8d' \
|
||||
| tac | sed "1,20d" | tac > $@
|
||||
|
||||
website-assets: doc all_examples grammar.html catala.html
|
||||
website-assets: doc literate_examples grammar.html catala.html
|
||||
|
||||
##########################################
|
||||
# Misceallenous
|
||||
##########################################
|
||||
|
||||
all: install-dependencies build doc tests all_examples website-assets
|
||||
all: install-dependencies build doc tests literate_examples website-assets
|
||||
|
||||
clean:
|
||||
dune clean
|
||||
@ -168,6 +174,6 @@ inspect:
|
||||
##########################################
|
||||
# Special targets
|
||||
##########################################
|
||||
.PHONY: inspect clean all all_examples english allocations_familiales pygments \
|
||||
.PHONY: inspect clean all literate_examples english allocations_familiales pygments \
|
||||
install build format install-dependencies install-dependencies-ocaml \
|
||||
catala.html
|
||||
|
12
examples/Makefile
Normal file
12
examples/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
test_us_tax_code:
|
||||
@SCOPE="TestSection132_1" $(MAKE) --no-print-directory -C us_tax_code tests/master_section_132.run \
|
||||
> /dev/null || { echo "[FAIL us_tax_code/section_132.catala_en (1/3)]"; exit 1; }
|
||||
@echo "[PASS us_tax_code/section_132.catala_en (1/3)]"
|
||||
@SCOPE="TestSection132_2" $(MAKE) --no-print-directory -C us_tax_code tests/master_section_132.run \
|
||||
> /dev/null || { echo "[FAIL us_tax_code/section_132.catala_en (1/3)]"; exit 1; }
|
||||
@echo "[PASS us_tax_code/section_132.catala_en (2/3)]"
|
||||
@SCOPE="TestSection132_3" $(MAKE) --no-print-directory -C us_tax_code tests/master_section_132.run \
|
||||
> /dev/null || { echo "[FAIL us_tax_code/section_132.catala_en (1/3)]"; exit 1; }
|
||||
@echo "[PASS us_tax_code/section_132.catala_en (3/3)]"
|
||||
|
||||
test_examples: test_us_tax_code
|
@ -7,7 +7,7 @@ LATEXMK=latexmk
|
||||
PYGMENTIZE_FR=../../syntax_highlighting/fr/pygments/pygments/env/bin/pygmentize
|
||||
PYGMENTIZE_EN=../../syntax_highlighting/en/pygments/pygments/env/bin/pygmentize
|
||||
|
||||
CATALA=dune exec --no-print-director ../../src/catala.exe -- --debug --language=$(CATALA_LANG)
|
||||
CATALA=dune exec --no-print-director ../../src/catala.exe -- $(CATALA_OPTS) --language=$(CATALA_LANG)
|
||||
|
||||
LEGIFRANCE_CATALA=dune exec ../../src/legifrance_catala.exe --
|
||||
|
||||
@ -29,14 +29,14 @@ endif
|
||||
##########################################
|
||||
|
||||
%.run: %.catala_$(CATALA_LANG) $(CATALA_EXE)
|
||||
$(CATALA) Makefile $<
|
||||
$(CATALA) \
|
||||
@$(CATALA) Makefile $<
|
||||
@$(CATALA) \
|
||||
Interpret \
|
||||
-s $(SCOPE) \
|
||||
$<
|
||||
|
||||
%.tex: %.catala_$(CATALA_LANG) $(CATALA_EXE)
|
||||
$(CATALA) Makefile $<
|
||||
@$(CATALA) Makefile $<
|
||||
$(CATALA) \
|
||||
--wrap \
|
||||
--pygmentize=$(PYGMENTIZE) \
|
||||
@ -44,7 +44,7 @@ endif
|
||||
$<
|
||||
|
||||
%.html: %.catala_$(CATALA_LANG) $(CATALA_EXE)
|
||||
$(CATALA) Makefile $<
|
||||
@$(CATALA) Makefile $<
|
||||
$(CATALA) \
|
||||
--wrap \
|
||||
--pygmentize=$(PYGMENTIZE) \
|
||||
|
@ -58,6 +58,12 @@ equals
|
||||
customer_price *$ 20%
|
||||
then customer_price *$ 20%
|
||||
else employee_discount
|
||||
|
||||
scope QualifiedEmployeeDiscount under condition is_services:
|
||||
# When selling a service, one does not need the aggregate cost.
|
||||
# We provide a default value here so that the computations run smooth.
|
||||
definition aggregate_cost equals $0
|
||||
definition gross_profit_percentage equals 0%
|
||||
*/
|
||||
@@(2) Gross profit percentage@@++
|
||||
|
||||
@ -69,8 +75,7 @@ to customers over the aggregate cost of such property to the employer, is of
|
||||
|
||||
(ii) the aggregate sale price of such property.
|
||||
/*
|
||||
scope QualifiedEmployeeDiscount
|
||||
under condition is_property :
|
||||
scope QualifiedEmployeeDiscount under condition is_property:
|
||||
assertion customer_price >=$ aggregate_cost
|
||||
|
||||
definition gross_profit_percentage equals
|
||||
@ -98,7 +103,7 @@ an employee for use by such employee, is less than
|
||||
employer to customers.
|
||||
/*
|
||||
scope QualifiedEmployeeDiscount:
|
||||
assertion customer_price >= employee_price
|
||||
assertion customer_price >=$ employee_price
|
||||
|
||||
definition employee_discount equals
|
||||
customer_price -$ employee_price
|
||||
|
@ -3,58 +3,39 @@
|
||||
/*
|
||||
declaration scope TestSection132_1:
|
||||
context section_132 scope QualifiedEmployeeDiscount
|
||||
context qualified_employee_discount content money
|
||||
context employee_discount content money
|
||||
context gross_profit_percentage content decimal
|
||||
|
||||
scope TestSection132_1:
|
||||
definition section_132.customer_price equals $1500
|
||||
definition section_132.employee_price equals $1000
|
||||
definition section_132.aggregate_cost equals $900
|
||||
definition section_132.discount_type equals Property
|
||||
definition employee_discount equals
|
||||
section_132.employee_discount
|
||||
definition gross_profit_percentage equals
|
||||
section_132.gross_profit_percentage
|
||||
definition qualified_employee_discount equals
|
||||
section_132.qualified_employee_discount
|
||||
assertion section_132.employee_discount = $500
|
||||
assertion section_132.gross_profit_percentage = 0.4
|
||||
assertion section_132.qualified_employee_discount = $500
|
||||
*/
|
||||
|
||||
/*
|
||||
declaration scope TestSection132_2:
|
||||
context section_132 scope QualifiedEmployeeDiscount
|
||||
context qualified_employee_discount content money
|
||||
context employee_discount content money
|
||||
context gross_profit_percentage content decimal
|
||||
|
||||
scope TestSection132_2:
|
||||
definition section_132.customer_price equals $1500
|
||||
definition section_132.employee_price equals $1000
|
||||
definition section_132.aggregate_cost equals $1200
|
||||
definition section_132.discount_type equals Property
|
||||
definition employee_discount equals
|
||||
section_132.employee_discount
|
||||
definition gross_profit_percentage equals
|
||||
section_132.gross_profit_percentage
|
||||
definition qualified_employee_discount equals
|
||||
section_132.qualified_employee_discount
|
||||
assertion section_132.employee_discount = $500
|
||||
assertion section_132.gross_profit_percentage = 0.2
|
||||
assertion section_132.qualified_employee_discount = $300.00
|
||||
*/
|
||||
|
||||
/*
|
||||
declaration scope TestSection132_3:
|
||||
context section_132 scope QualifiedEmployeeDiscount
|
||||
context qualified_employee_discount content money
|
||||
context employee_discount content money
|
||||
context gross_profit_percentage content decimal
|
||||
|
||||
scope TestSection132_3:
|
||||
definition section_132.customer_price equals $1500
|
||||
definition section_132.employee_price equals $1000
|
||||
definition section_132.discount_type equals Services
|
||||
definition employee_discount equals
|
||||
section_132.employee_discount
|
||||
definition gross_profit_percentage equals
|
||||
section_132.gross_profit_percentage
|
||||
definition qualified_employee_discount equals
|
||||
section_132.qualified_employee_discount
|
||||
assertion section_132.employee_discount = $500
|
||||
assertion section_132.qualified_employee_discount = $300
|
||||
*/
|
@ -450,6 +450,34 @@ let process_rule (precond : Scopelang.Ast.expr Pos.marked Bindlib.box option)
|
||||
in
|
||||
process_def precond scope ctxt prgm def
|
||||
|
||||
(** Process an assertion from the surface language *)
|
||||
let process_assert (precond : Scopelang.Ast.expr Pos.marked Bindlib.box option)
|
||||
(scope_uid : Scopelang.Ast.ScopeName.t) (ctxt : Name_resolution.context)
|
||||
(prgm : Desugared.Ast.program) (ass : Ast.assertion) : Desugared.Ast.program =
|
||||
let scope : Desugared.Ast.scope = Scopelang.Ast.ScopeMap.find scope_uid prgm.program_scopes in
|
||||
let ass =
|
||||
translate_expr scope_uid None ctxt
|
||||
( match ass.Ast.assertion_condition with
|
||||
| None -> ass.Ast.assertion_content
|
||||
| Some cond ->
|
||||
( Ast.IfThenElse
|
||||
(cond, ass.Ast.assertion_content, Pos.same_pos_as (Ast.Literal (Ast.Bool true)) cond),
|
||||
Pos.get_position cond ) )
|
||||
in
|
||||
let ass =
|
||||
match precond with
|
||||
| Some precond ->
|
||||
Bindlib.box_apply2
|
||||
(fun precond ass ->
|
||||
( Scopelang.Ast.EIfThenElse
|
||||
(precond, ass, Pos.same_pos_as (Scopelang.Ast.ELit (Dcalc.Ast.LBool true)) precond),
|
||||
Pos.get_position precond ))
|
||||
precond ass
|
||||
| None -> ass
|
||||
in
|
||||
let new_scope = { scope with scope_assertions = ass :: scope.scope_assertions } in
|
||||
{ prgm with program_scopes = Scopelang.Ast.ScopeMap.add scope_uid new_scope prgm.program_scopes }
|
||||
|
||||
let process_scope_use_item (precond : Ast.expression Pos.marked option)
|
||||
(scope : Scopelang.Ast.ScopeName.t) (ctxt : Name_resolution.context)
|
||||
(prgm : Desugared.Ast.program) (item : Ast.scope_use_item Pos.marked) : Desugared.Ast.program =
|
||||
@ -457,6 +485,7 @@ let process_scope_use_item (precond : Ast.expression Pos.marked option)
|
||||
match Pos.unmark item with
|
||||
| Ast.Rule rule -> process_rule precond scope ctxt prgm rule
|
||||
| Ast.Definition def -> process_def precond scope ctxt prgm def
|
||||
| Ast.Assertion ass -> process_assert precond scope ctxt prgm ass
|
||||
| _ -> prgm
|
||||
|
||||
let process_scope_use (ctxt : Name_resolution.context) (prgm : Desugared.Ast.program)
|
||||
|
@ -75,6 +75,7 @@ type expr =
|
||||
| ELit of lit
|
||||
| EAbs of Pos.t * (expr, expr Pos.marked) Bindlib.mbinder * typ Pos.marked list
|
||||
| EApp of expr Pos.marked * expr Pos.marked list
|
||||
| EAssert of expr Pos.marked
|
||||
| EOp of operator
|
||||
| EDefault of expr Pos.marked * expr Pos.marked * expr Pos.marked list
|
||||
| EIfThenElse of expr Pos.marked * expr Pos.marked * expr Pos.marked
|
||||
|
@ -107,6 +107,7 @@ let evaluate_operator (op : A.operator Pos.marked) (args : A.expr Pos.marked lis
|
||||
| A.Binop A.Eq, [ ELit (LDuration i1); ELit (LDuration i2) ] -> A.ELit (LBool (i1 = i2))
|
||||
| A.Binop A.Eq, [ ELit (LDate i1); ELit (LDate i2) ] ->
|
||||
A.ELit (LBool (ODate.Unix.compare i1 i2 = 0))
|
||||
| A.Binop A.Eq, [ ELit (LMoney i1); ELit (LMoney i2) ] -> A.ELit (LBool (i1 = i2))
|
||||
| A.Binop A.Eq, [ ELit (LRat i1); ELit (LRat i2) ] -> A.ELit (LBool Q.(i1 = i2))
|
||||
| A.Binop A.Eq, [ ELit (LInt i1); ELit (LInt i2) ] -> A.ELit (LBool (i1 = i2))
|
||||
| A.Binop A.Eq, [ ELit (LBool b1); ELit (LBool b2) ] -> A.ELit (LBool (b1 = b2))
|
||||
@ -114,6 +115,7 @@ let evaluate_operator (op : A.operator Pos.marked) (args : A.expr Pos.marked lis
|
||||
| A.Binop A.Neq, [ ELit (LDuration i1); ELit (LDuration i2) ] -> A.ELit (LBool (i1 <> i2))
|
||||
| A.Binop A.Neq, [ ELit (LDate i1); ELit (LDate i2) ] ->
|
||||
A.ELit (LBool (ODate.Unix.compare i1 i2 <> 0))
|
||||
| A.Binop A.Neq, [ ELit (LMoney i1); ELit (LMoney i2) ] -> A.ELit (LBool (i1 <> i2))
|
||||
| A.Binop A.Neq, [ ELit (LRat i1); ELit (LRat i2) ] -> A.ELit (LBool Q.(i1 <> i2))
|
||||
| A.Binop A.Neq, [ ELit (LInt i1); ELit (LInt i2) ] -> A.ELit (LBool (i1 <> i2))
|
||||
| A.Binop A.Neq, [ ELit (LBool b1); ELit (LBool b2) ] -> A.ELit (LBool (b1 <> b2))
|
||||
@ -258,6 +260,15 @@ let rec evaluate_expr (e : A.expr Pos.marked) : A.expr Pos.marked =
|
||||
"Expected a boolean literal for the result of this condition (should not happen if the \
|
||||
term was well-typed)"
|
||||
(Pos.get_position cond) )
|
||||
| EAssert e' -> (
|
||||
match Pos.unmark (evaluate_expr e') with
|
||||
| ELit (LBool true) -> Pos.same_pos_as (Ast.ELit LUnit) e'
|
||||
| ELit (LBool false) -> Errors.raise_spanned_error "Assertion failed" (Pos.get_position e')
|
||||
| _ ->
|
||||
Errors.raise_spanned_error
|
||||
"Expected a boolean literal for the result of this assertion (should not happen if the \
|
||||
term was well-typed)"
|
||||
(Pos.get_position e') )
|
||||
|
||||
let empty_thunked_term : Ast.expr Pos.marked =
|
||||
let silent = Ast.Var.make ("_", Pos.no_pos) in
|
||||
|
@ -193,3 +193,4 @@ let rec format_expr (fmt : Format.formatter) (e : expr Pos.marked) : unit =
|
||||
Format.fprintf fmt "@[<hov 2>⟨%a ⊢ %a |@ %a⟩@]" format_expr just format_expr cons
|
||||
(Format.pp_print_list ~pp_sep:(fun fmt () -> Format.fprintf fmt ",@ ") format_expr)
|
||||
subs
|
||||
| EAssert e' -> Format.fprintf fmt "@[<hov 2>assert@ (%a)@]" format_expr e'
|
||||
|
@ -239,6 +239,9 @@ let rec typecheck_expr_bottom_up (env : env) (e : A.expr Pos.marked) : typ Pos.m
|
||||
let tt = typecheck_expr_bottom_up env et in
|
||||
typecheck_expr_top_down env ef tt;
|
||||
tt
|
||||
| EAssert e' ->
|
||||
typecheck_expr_top_down env e' (UnionFind.make (Pos.same_pos_as (TLit TBool) e'));
|
||||
UnionFind.make (Pos.same_pos_as (TLit TUnit) e')
|
||||
|
||||
and typecheck_expr_top_down (env : env) (e : A.expr Pos.marked)
|
||||
(tau : typ Pos.marked UnionFind.elem) : unit =
|
||||
@ -364,6 +367,9 @@ and typecheck_expr_top_down (env : env) (e : A.expr Pos.marked)
|
||||
typecheck_expr_top_down env cond (UnionFind.make (Pos.same_pos_as (TLit TBool) cond));
|
||||
typecheck_expr_top_down env et tau;
|
||||
typecheck_expr_top_down env ef tau
|
||||
| EAssert e' ->
|
||||
typecheck_expr_top_down env e' (UnionFind.make (Pos.same_pos_as (TLit TBool) e'));
|
||||
unify tau (UnionFind.make (Pos.same_pos_as (TLit TUnit) e'))
|
||||
|
||||
let infer_type (e : A.expr Pos.marked) : A.typ Pos.marked =
|
||||
let ty = typecheck_expr_bottom_up A.VarMap.empty e in
|
||||
|
@ -70,7 +70,7 @@ let empty_rule (pos : Pos.t) (have_parameter : Scopelang.Ast.typ Pos.marked opti
|
||||
parent_rule = None;
|
||||
}
|
||||
|
||||
type assertion = Scopelang.Ast.expr Pos.marked
|
||||
type assertion = Scopelang.Ast.expr Pos.marked Bindlib.box
|
||||
|
||||
type variation_typ = Increasing | Decreasing
|
||||
|
||||
|
@ -142,10 +142,6 @@ let translate_scope (scope : Ast.scope) : Scopelang.Ast.scope_decl =
|
||||
(fun vertex ->
|
||||
match vertex with
|
||||
| Dependency.Vertex.Var (var : Scopelang.Ast.ScopeVar.t) ->
|
||||
(* Cli.debug_print (Format.asprintf "Finding %a in %a"
|
||||
Scopelang.Ast.ScopeVar.format_t var (Format.pp_print_list ~pp_sep:(fun fmt () ->
|
||||
Format.fprintf fmt ", ") (fun fmt (d, _) -> Format.fprintf fmt "%a"
|
||||
Ast.ScopeDef.format_t d)) (Ast.ScopeDefMap.bindings scope.scope_defs)); *)
|
||||
let var_def, var_typ =
|
||||
Ast.ScopeDefMap.find (Ast.ScopeDef.Var var) scope.scope_defs
|
||||
in
|
||||
@ -199,6 +195,11 @@ let translate_scope (scope : Ast.scope) : Scopelang.Ast.scope_decl =
|
||||
sub_scope_vars_redefs @ [ Scopelang.Ast.Call (sub_scope, sub_scope_index) ])
|
||||
scope_ordering)
|
||||
in
|
||||
(* Then, after having computed all the scopes variables, we add the assertions *)
|
||||
let scope_decl_rules =
|
||||
scope_decl_rules
|
||||
@ List.map (fun e -> Scopelang.Ast.Assertion (Bindlib.unbox e)) scope.Ast.scope_assertions
|
||||
in
|
||||
let scope_sig =
|
||||
Scopelang.Ast.ScopeVarSet.fold
|
||||
(fun var acc ->
|
||||
|
@ -130,6 +130,9 @@ let driver (source_file : string) (debug : bool) (unstyled : bool) (wrap_weaved_
|
||||
(fun (v1, _) (v2, _) -> String.compare (Bindlib.name_of v1) (Bindlib.name_of v2))
|
||||
results
|
||||
in
|
||||
Cli.result_print
|
||||
(Format.asprintf "Computation successful!%s"
|
||||
(if List.length results > 0 then " Results:" else ""));
|
||||
List.iter
|
||||
(fun (var, result) ->
|
||||
Cli.result_print
|
||||
|
@ -142,6 +142,7 @@ module VarMap = Map.Make (Var)
|
||||
|
||||
type rule =
|
||||
| Definition of location Pos.marked * typ Pos.marked * expr Pos.marked
|
||||
| Assertion of expr Pos.marked
|
||||
| Call of ScopeName.t * SubScopeName.t
|
||||
|
||||
type scope_decl = {
|
||||
|
@ -54,7 +54,7 @@ let build_program_dep_graph (prgm : Ast.program) : SDependencies.t =
|
||||
List.fold_left
|
||||
(fun acc r ->
|
||||
match r with
|
||||
| Ast.Definition _ -> acc
|
||||
| Ast.Definition _ | Ast.Assertion _ -> acc
|
||||
| Ast.Call (subscope, subindex) ->
|
||||
if subscope = scope_name then
|
||||
Errors.raise_spanned_error
|
||||
|
@ -227,10 +227,10 @@ let rec translate_expr (ctx : ctx) (e : Ast.expr Pos.marked) : Dcalc.Ast.expr Po
|
||||
with Not_found ->
|
||||
Errors.raise_spanned_error
|
||||
(Format.asprintf
|
||||
"The variable %a.%a cannot be used here, as subscope %a's results will not have \
|
||||
been computed yet"
|
||||
Ast.SubScopeName.format_t (Pos.unmark s) Ast.ScopeVar.format_t (Pos.unmark a)
|
||||
Ast.SubScopeName.format_t (Pos.unmark s))
|
||||
"The variable %a.%a cannot be used here,\n\
|
||||
as subscope %a's results will not have been computed yet" Ast.SubScopeName.format_t
|
||||
(Pos.unmark s) Ast.ScopeVar.format_t (Pos.unmark a) Ast.SubScopeName.format_t
|
||||
(Pos.unmark s))
|
||||
(Pos.get_position e) )
|
||||
| EIfThenElse (cond, et, ef) ->
|
||||
Bindlib.box_apply3
|
||||
@ -380,6 +380,15 @@ let rec translate_rule (ctx : ctx) (rule : Ast.rule) (rest : Ast.rule list) (pos
|
||||
pos_sigma )
|
||||
call_expr results_bindings,
|
||||
new_ctx )
|
||||
| Assertion e ->
|
||||
let next_e, new_ctx = translate_rules ctx rest pos_sigma in
|
||||
let new_e = translate_expr ctx e in
|
||||
( Dcalc.Ast.make_let_in
|
||||
(Dcalc.Ast.Var.make ("_", Pos.no_pos))
|
||||
(Dcalc.Ast.TLit TUnit, Pos.no_pos)
|
||||
(Bindlib.box_apply (fun new_e -> Pos.same_pos_as (Dcalc.Ast.EAssert new_e) e) new_e)
|
||||
next_e,
|
||||
new_ctx )
|
||||
|
||||
and translate_rules (ctx : ctx) (rules : Ast.rule list) (pos_sigma : Pos.t) :
|
||||
Dcalc.Ast.expr Pos.marked Bindlib.box * ctx =
|
||||
@ -412,7 +421,7 @@ let translate_scope_decl (struct_ctx : Ast.struct_ctx) (enum_ctx : Ast.enum_ctx)
|
||||
scope_variables
|
||||
in
|
||||
Dcalc.Ast.make_abs
|
||||
(Array.of_list ((List.map (fun (_, _, x) -> x)) scope_variables))
|
||||
(Array.of_list (List.map (fun (_, _, x) -> x) scope_variables))
|
||||
rules pos_sigma
|
||||
(List.map
|
||||
(fun (_, tau, _) ->
|
||||
|
@ -1,2 +1,3 @@
|
||||
[RESULT] bar -> 1
|
||||
[RESULT] foo -> true
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] bar = 1
|
||||
[RESULT] foo = true
|
||||
|
@ -1,4 +1,5 @@
|
||||
[RESULT] x -> 2019-01-01
|
||||
[RESULT] y -> 2002-09-30
|
||||
[RESULT] z -> true
|
||||
[RESULT] z2 -> true
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] x = 2019-01-01
|
||||
[RESULT] y = 2002-09-30
|
||||
[RESULT] z = true
|
||||
[RESULT] z2 = true
|
||||
|
@ -1,3 +1,4 @@
|
||||
[RESULT] x -> 2019-01-01
|
||||
[RESULT] y -> 2002-09-30
|
||||
[RESULT] z -> 5937 days
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] x = 2019-01-01
|
||||
[RESULT] y = 2002-09-30
|
||||
[RESULT] z = 5937 days
|
||||
|
@ -1,4 +1,6 @@
|
||||
[RESULT] a -> -0.000000000000000000000000000000000000000000000000000000000078695580959228473468…
|
||||
[RESULT] x -> 84.64866565265689623
|
||||
[RESULT] y -> -4.3682977870532065498
|
||||
[RESULT] z -> 654265429805103220650980650.570540510654
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] a =
|
||||
[RESULT] -0.000000000000000000000000000000000000000000000000000000000078695580959228473468…
|
||||
[RESULT] x = 84.64866565265689623
|
||||
[RESULT] y = -4.3682977870532065498
|
||||
[RESULT] z = 654265429805103220650980650.570540510654
|
||||
|
@ -1,3 +1,4 @@
|
||||
[RESULT] x -> 84.0648665
|
||||
[RESULT] y -> 4.368297
|
||||
[RESULT] z -> 19.24431111254569000230…
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] x = 84.0648665
|
||||
[RESULT] y = 4.368297
|
||||
[RESULT] z = 19.24431111254569000230…
|
||||
|
@ -1,2 +1,3 @@
|
||||
[RESULT] x -> Case1 2
|
||||
[RESULT] y -> 42
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] x = Case1 2
|
||||
[RESULT] y = 42
|
||||
|
@ -1 +1,2 @@
|
||||
[RESULT] r -> 30
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] r = 30
|
||||
|
@ -18,7 +18,7 @@
|
||||
[ERROR] 12 | def z := (x *$ y)
|
||||
[ERROR] | ^^
|
||||
[ERROR]
|
||||
[ERROR] Type money → any type coming from expression:
|
||||
[ERROR] Type money → money coming from expression:
|
||||
[ERROR] --> test_money/no_mingle.catala
|
||||
[ERROR] |
|
||||
[ERROR] 12 | def z := (x *$ y)
|
||||
@ -30,7 +30,7 @@
|
||||
[ERROR] 12 | def z := (x *$ y)
|
||||
[ERROR] | ^^
|
||||
[ERROR]
|
||||
[ERROR] Type money → money → any type coming from expression:
|
||||
[ERROR] Type money → money → money coming from expression:
|
||||
[ERROR] --> test_money/no_mingle.catala
|
||||
[ERROR] |
|
||||
[ERROR] 12 | def z := (x *$ y)
|
||||
|
@ -1,3 +1,4 @@
|
||||
[RESULT] x -> $123.54
|
||||
[RESULT] y -> $8548650.96
|
||||
[RESULT] z -> $7.23
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] x = $123.54
|
||||
[RESULT] y = $8548650.96
|
||||
[RESULT] z = $7.23
|
||||
|
@ -1 +1,2 @@
|
||||
[RESULT] x -> 0
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] x = 0
|
||||
|
@ -1,2 +1,3 @@
|
||||
[RESULT] y1 -> 1
|
||||
[RESULT] y2 -> 1
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] y1 = 1
|
||||
[RESULT] y2 = 1
|
||||
|
@ -1,2 +1,3 @@
|
||||
[RESULT] z1 -> 2
|
||||
[RESULT] z2 -> 2
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] z1 = 2
|
||||
[RESULT] z2 = 2
|
||||
|
@ -1,3 +1,4 @@
|
||||
[RESULT] a -> -1
|
||||
[RESULT] a_base -> 1
|
||||
[RESULT] b -> false
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] a = -1
|
||||
[RESULT] a_base = 1
|
||||
[RESULT] b = false
|
||||
|
@ -1,2 +1,3 @@
|
||||
[RESULT] a -> 42
|
||||
[RESULT] b -> true
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] a = 42
|
||||
[RESULT] b = true
|
||||
|
@ -1,2 +1,3 @@
|
||||
[RESULT] u -> true
|
||||
[RESULT] x -> 0
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] u = true
|
||||
[RESULT] x = 0
|
||||
|
@ -1 +1,2 @@
|
||||
[RESULT] z -> 2
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] z = 2
|
||||
|
@ -1 +1,2 @@
|
||||
[RESULT] t -> ("a": ("x": 0,"y": false),"b": ("x": 1,"y": true))
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] t = ("a": ("x": 0,"y": false),"b": ("x": 1,"y": true))
|
||||
|
@ -1,2 +1,3 @@
|
||||
[RESULT] out -> 1
|
||||
[RESULT] t -> ("a": ("x": 0,"y": false),"b": ("x": 1,"y": true))
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] out = 1
|
||||
[RESULT] t = ("a": ("x": 0,"y": false),"b": ("x": 1,"y": true))
|
||||
|
@ -1,2 +1,3 @@
|
||||
[RESULT] s -> ("x": 1,"y": 2)
|
||||
[RESULT] z -> 3
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] s = ("x": 1,"y": 2)
|
||||
[RESULT] z = 3
|
||||
|
Loading…
Reference in New Issue
Block a user