123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204openAlba_coreopenAstmoduleInductive_parser=Parser_lang.Make(structtypet=Source_entry.inductivearrayend)moduleExpression_parser=Parser_lang.Make(Expression)moduleDefinition_parser=Parser_lang.Make(structtypet=Expression.definitionend)letadd_definition(src:string)(c:Context.t):Context.t=letopenDefinition_parserinletp=run(global_definition())srcinassert(has_endedp);assert(has_succeededp);matchresultpwith|None->assertfalse(* Cannot happen. *)|Somedef->matchBuilder.add_definitiondefcwith|Error_->assertfalse|Okc->cletadd_inductive(src:string)(c:Context.t):Context.t=letopenInductive_parserinletp=run(inductive_family())srcinassert(has_endedp);assert(has_succeededp);matchresultpwith|None->assertfalse(* Cannot happen. *)|Somedef->matchBuilder.add_inductivedefcwith|Error_->Printf.printf"Standard_context.add_inductive\n%s\n"src;assertfalse|Okc->cletadd_builtin(fun_flag:bool)(descr:string)(name:string)(src:string)(c:Context.t):Context.t=letopenExpression_parserinletp=run(expression())srcinassert(has_endedp);assert(has_succeededp);matchresultpwith|None->assertfalse(* Cannot happen. *)|Someexp->matchBuild_expression.buildexpcwith|Error_->assertfalse|Ok(typ,_)->iffun_flagthenContext.add_builtin_functiondescrnametypcelseContext.add_builtin_typedescrnametypcletadd_logic(c:Context.t):Context.t=c|>add_definition"Predicate (A: Any): Any := A -> Proposition"|>add_definition"Relation (A: Any) (B: Any): Any := A -> B -> Proposition"|>add_definition"Endorelation (A: Any): Any := Relation A A"|>add_inductive"class (=) (A: Any) (a: A): Predicate A := identical: a = a"|>add_definition"(=>) (a: Proposition) (b: Proposition): Proposition :=\
\n a -> b"|>add_inductive"class false: Proposition :="|>add_definition"(not) (a: Proposition): Proposition := a => false"|>add_inductive"class true: Proposition := trueValid"|>add_inductive"class (and) (a: Proposition) (b: Proposition): Proposition :=\
\n (,): a => b => a and b"|>add_inductive"class (or) (a: Proposition) (b: Proposition): Proposition :=\
\n left: a => a or b\
\n right: b => a or b"|>add_inductive"class exist (A: Any) (f: A -> Proposition): Proposition :=\
\n witness (a: A): f a => exist f"letadd_basics(c:Context.t):Context.t=c|>add_definition"identity (A: Any) (a: A): A := a"|>add_definition"(|>) (A: Any) (a: A) (F: A -> Any) (f: all x: F x): F a := f a"|>add_definition"(<|) (A: Any) (F: A -> Any) (f: all x: F x) (a: A): F a := f a"|>add_definition"(>>) (A: Any) (B: Any) (C: Any) (f: A -> B) (g: B -> C): A -> C :=
\n \\x := g (f x)"|>add_definition"(<<) (A: Any) (B: Any) (C: Any) (f: B -> C) (g: A -> B): A -> C :=
\n \\x := f (g x)"|>add_inductive"class Decision (a: Proposition) (b: Proposition): Any := \
\n left: a -> Decision a b
\n right: b -> Decision a b"|>add_inductive"class Maybe (A: Any): Any := \
\n nothing: Maybe A\
\n just : A -> Maybe A"|>add_inductive"class List (A: Any): Any := \
\n []: List A\
\n (+:): A -> List A -> List A"letadd_builtins(c:Context.t):Context.t=c|>add_builtinfalse"int_type""Int""Any"|>add_builtintrue"int_plus""+""Int -> Int -> Int"|>add_builtintrue"int_minus""-""Int -> Int -> Int"|>add_builtintrue"int_negate""-""Int -> Int"|>add_builtintrue"int_times""*""Int -> Int -> Int"|>add_builtinfalse"string_type""String""Any"|>add_builtintrue"string_concat""+""String -> String -> String"|>add_builtinfalse"character_type""Character""Any"letmake():Context.t=Context.empty|>add_logic|>add_builtins|>add_basicslet_=make()